4
votes

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!

3
Do you have the source code for the assembly?Davin Tryon
No, but it is a Matlab complied dll. the exception thrown in this line: double[,] values = (double[,])MWNA.ToArray(MWArrayComponent.Real);Charla
And the MWNA object is an instance of this assembly.Charla
Do you have to compile your assembly as .NET 4 (the one referencing the Matlab assembly)?Davin Tryon

3 Answers

8
votes

You can also try useLegacyV2RuntimeActivationPolicy="true"

   <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
5
votes

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>
0
votes

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.