tags:

views:

28

answers:

1

I have a project that was created with VS2008. I'm trying to build it with MSBuild 4.0, but still targeting the 3.5 framework. When I do so, I get the exception:

[exec] ResGen : error RG0000: Could not load referenced assembly "C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationUI\v4.0_4.0.0.0__31bf3856ad364e35\PresentationUI.dll". Caught a BadImageFormatException saying "Could not load file or assembly 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationUI\v4.0_4.0.0.0__31bf3856ad364e35\PresentationUI.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.".

Note that it's trying to load the 4.0 version of PresentationUI.dll, even though I'm compiling for the 3.5 framework. It doesn't matter if I convert the project to VS2010 format or not, the error is the same.

+2  A: 

The problem turned out to be that the HintPath of the PresentationUI.dll assembly didn't match the actual assembly location. In that case, MSBuild falls back to looking for the assembly in the GAC. Since MSBuild 4.0 runs on the .NET 4.0 runtime, it picks up the 4.0 version of the assembly, which is incompatible with the 3.5 project being compiled.

Kevin Dente