The mixed-mode assembly is built in comparison with the version "v2.0.50727" of the runtime environment and cannot be loaded into the runtime environment 4.0

I got this exception after running execuable at the command prompt:

'Mixed mode assembly built against runtime version v2.0.50727' and cannot be loaded into runtime 4.0 without additional configuration information.

After searching for this problem on the Internet, I found one way to configure the App.Config file. This works fine in VS2010, but still generates the same error in command mode.

So, is there a way to resolve this using the command line, since it is not possible to generate a newer version of .dll.

Thanks!

+4
source share
3 answers

Make sure you configure the App.config and ProgramName.exe.config files.

For instance:

<configuration> <startup> <supportedRuntime version="v2.0.50727"/> </startup> </configuration> 
+5
source

You can also try useLegacyV2RuntimeActivationPolicy = "true"

  <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> 
+8
source

Another solution might be to recompile all mixed (C ++ / CLI) assemblies for which you are dependent on .NET 4.0. Often this is not possible if these assemblies are third-party.

0
source

All Articles