6
votes

I cannot build a project, written by an ex-employee, on my Windows 7 workstation. It works perfectly fine on the old XP machine he used and I have an exact copy.

Error 1 Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. C:\Working\Scan\v2.5.9.99\ConfigurationTool\ConfigurationTool\SGEN ConfigurationTool

I have already searched for a solution to this error message but I have found that the solutions provided do not resolve the problem :(

This is how my config file started off, useLegacyV2RuntimeActivationPolicy is already present.

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
    <requiredRuntime version="v4.0.20506"/>
  </startup>
</configuration>

I have tried every suggested combination as well as different profile for full and client versions, as outlined in this thread with no results.

What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?

Has anyone got a fix or any ideas on what could be causing the difference between the copies on different machines?

3
IMPORTANT: If the error happens with error column "File" as SGEN, then the fix needs to be in a file sgen.exe.config, next to sgen.exe. For example, for VS 2015, create C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\sgen.exe.config. Source: SGEN Mixed mode assembly Minimum file contents: <configuration><startup useLegacyV2RuntimeActivationPolicy="true"/></configuration>ToolmakerSteve

3 Answers

6
votes

Just solved it try this:

  1. Make sure that if you have more than one project they are all set to build for .net 4 full not client.
  2. If you keep getting the compiler error set the "Generate serialization assembly" to OFF
  3. If you are building a plug-in and the output of your project is a dll you have to create a config file for that program (i had to create "INFOPATH.EXE.config")

Hope it helps

0
votes

For us this thread helped: http://social.msdn.microsoft.com/Forums/en/clr/thread/2a5bf31e-df96-4bf1-a846-699da46b62fb

"Generate serialization assembly" was set to AUTO and we didn't feel comfortable turning it OFF if VS (in release mode) was trying to generate it. What the thread told us was that sgen.exe could be (and maybe already should have been) told to "useLegacyV2RuntimeActivationPolicy" just like we were trying to do in our own app.config. Pretty obscure.

0
votes

I have tried the following code works for me, both two version 2 and 4 assembly works

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
</startup>

this could help