6
votes

We have a ASP.Net web application running in Visual Studio 2010 that is targeting .Net 3.5. It's being built by TFS 2010. This web application has a couple web references, so the build creates a related XmlSerializers DLL. This DLL, however, is a .Net 4.0 assembly.

When I run this web application from the build, I get the error:

Could not load file or assembly 'BLAH_BLAH_WEB_APPLICATION_NAME.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

We are using a msbuild .proj file that was working under TFS 2008 (using the "Upgrade Template" in the Build Definition). I saw this question and this one, but those mention using a specific SGen build step. We are not. Additionally, the proposed solution involve hard-coding the path to the 7.0A SGen, which is just...ugly.

Is there a way to force the TFS 2010 build to compile this XmlSerializers DLL as a .Net 3.5 Assembly?

2
Did you set the target framework on the serializer project to 3.5? Check project properties.Robaticus
I'm not sure what you mean by "the serializer project". The project that consumes the web references itself is targeting 3.5. Is there another setting for the web references?david.mchonechase

2 Answers

4
votes

The root problem was an invalid value in the registry. The SDK35ToolsPath value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0 was:

$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx35Tools-x86@InstallationFolder)

However, the build server had Windows SDK version 7.1. So, I corrected the value to be:

$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDKNetFx35Tools@InstallationFolder)

Then XmlSerializers DLL was now using .Net 2.0.

0
votes

I solved this issue via setting parameter named SGenToolPath

/p:SGenToolPath="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin"