VS 2010, TFS 2013 SGEN: An attempt was made to load an assembly with the wrong format

I am working on converting the definition of the tfs 2013 assembly, we originally used tfs 2008. I have a new server installed with TFS2013 installed and am working on setting up Build for 2013 xaml (workflow). However, I encountered an error when my TFS built in release mode for Any Cpu configuration, but it is fine when I use debug mode. I tried looking for a lot of articles and could not find any solution, kindly help me here. This is normal on my local machine, but only happens on the server.

Project and details

1) project -.net framework 4.0

2) The default configuration is "Any Cpu"

3) TFS 2013 server - 64 bit, Windows 2008 r2 server

Build definition

Configuration: any CPU | Release

MsBuildPlatform: x86

Error : SGEN: An attempt was made to load an assembly with the wrong format: C: \ Windows \ Microsoft.Net \ assembly \ GAC_64 \ System.Data \ v4.0_4.0.0.0__b77a5c561934e089 \ System.Data.dll.

Attention : C: \ Program Files (x86) \ MSBuild \ 12.0 \ bin \ Microsoft.Common.CurrentVersion.targets (990): link assemblies for the ".NETFramework, Version = v4.0" framework were not found. To solve this problem, install the SDK or Targeting Pack for this version of the framework or migrate the application to the version of the framework for which the SDK or Targeting Pack is installed. Note that assemblies will be resolved from the global assembly cache (GAC) and will be used instead of referenced assemblies. Therefore, your assembly may not be properly configured for the framework you are planning.

I installed Windos 8 SDK (only for tools) and Windows framework 4 x64 as x86 version does not work

In the folder C: \ Program Files \ Microsoft SDKs \ Windows, the folder v7.0 is installed C: \ Program Files (x86) \ Microsoft SDK \ Windows has the folder v8.1A

where since my local machine has many versions inside the windows folder in the above path

List of related articles I checked but could not find a solution

http://seravy.wordpress.com/2012/10/25/installing-net-4-5-and-not-windows-sdk-8/

http://blogs.msdn.com/b/windowssdk/archive/2009/09/16/windows-7-sdk-setup-common-installation-issues-and-fixes.aspx

Running MSBuild Cannot Read SDKToolsPath

http://dukelupus.wordpress.com/2008/02/05/task-failed-because-sgenexe-was-not-found-solution/

How to fix Visual Studio compilation error, "mismatch between processor architecture"?

Creating TFS 2010. Creating 4.0 XmlSerializers DLL for .Net 3.5 Application

So what should I do to fix this error?

+7
tfs build-process build msbuild tfs2013
source share
5 answers

You need to install targeting packages (e.g. SDK, aka Developer pack) for the .NET Framework that you are targeting. You can download them all from http://blogs.msdn.com/b/dotnet/p/dotnet_sdks.aspx

In particular, for your question and targeting the .NET Framework 4.0, you want the Windows SDK for Windows 7 and the .NET Framework 4. It looks like you grabbed the Windows 8 SDK, which is not intended to target the .NET Framework 4.0.

+4
source share

This is not a very good answer (but in case someone encounters it, like me), and does not make it clear why it happens. But disabling "Generate serialization assembly" in the intruder project allows the assembly to work in my case.

Startup time will be slower since serialization will now happen at run time.

+2
source share

You just need to see what structure you are using, and then what debugging mode you are using. In my case, I used the framework version 4.0 framework and the "any processor" build mode, but after searching I found that I need to upgrade my .NET infrastructure from 4.0 to 4.5, and I need to build my solution from "any processor" to x86 because I had x86 SPI Windows 7 architecture.

Here are some images I made to solve this error. enter image description hereenter image description here

+1
source share

I encountered this error (although for the newer version of the .NET framework version v4.5.1, not v4.0, as in the original question) when trying to create my application on the build server.

A combination of the following two conditions was responsible for the error:

  • In Visual Studio, on the "Project Properties" page on the "Application" tab in the "Target Structure", ".NET Framework 4.5.1" was installed;
  • On the build server, in the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework folder named v4.5.1 was missing. (Other folders with version numbers, including v3.5, v4.0, and v4.5, were present.)

This missing folder was the reason for the warning "Control assemblies for the framework ... were not found", which, in turn, leads to the error "assembly with the wrong format".

The fix was to install the Windows Development Kit (SDK) for Windows 8.1 on the build server. In the installation wizard, in the "Select the features you want to install" step, I unchecked the boxes without any except one for the ".NET Framework 4.5.1 Software Development Kit".

Starting this installation caused the v4.5.1 folder in the Reference Assemblies \ Microsoft \ Framework.NETFramework folder to disappear and the assembly to run successfully.

+1
source share

I am reluctant to answer because you say that you already did this, but every time I struggled with the error message that you are quoting, it was the MsBuildPlatform setting. It is absolutely necessary to set the value to "X86". Are you sure the setting is set.?

0
source share

All Articles