4

I got this exception after runing an execuable in command line execution:

"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."

After search this issue on internet, I found one of the way out is to configure App.Config file. That works fine in VS2010 but still generates same error in command mode.

So is there any way to resolve this by using command line as generating newer version of .dll is impossible.

Thanks!

Charla
  • 77
  • 1
  • 1
  • 6

3 Answers3

8

You can also try useLegacyV2RuntimeActivationPolicy="true"

   <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
Dmitry
  • 1,513
  • 1
  • 15
  • 33
  • I am facing same issue, but the thing is that a third party application is communicating with our application using a interface and the the interface is calling the 4.0 dll. The 4.0 dll is referring a dll built in v2.0.50727 and we do not have code for it. I am getting above exception while instantiating the v2.0.50727 dll. I have tried the above solutions but not worked, any suggestions? – user2067120 Oct 06 '15 at 10:29
  • does no work either? – Dmitry Oct 06 '15 at 13:50
5

Make sure you have configured both the App.config and the ProgramName.exe.config file.

For example:

<configuration>
    <startup>
      <supportedRuntime version="v2.0.50727"/>
   </startup>
 </configuration>
Adam Baxter
  • 1,907
  • 21
  • 41
0

Another solution can be to recompile all mixed(C++/CLI) assemblies you are dependent on for .NET 4.0. It is often not possible if these assemblies are third party.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148