FileLoadException: 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.

Situation: You’re running an application using JNBridgePro and you encounter a System.IO.FileLoadException with the message “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.”

This can occur when you’re running an application that uses the .NET 4.0/4.5/4.6 runtime, and your application attempts to load a .NET 2.0/3.0/3.5-targeted DLL that has certain properties.

When you encounter this, you can fix the problem by editing the application’s app.config file.  Add the following element to the app.config file (inside the <configuration> element):


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

If the <startup> element is already there, simply add the portions that aren’t currently there.

The problem can also occur when attempting to generate Java proxies from certain .NET 2.0/3.0/3.5-targeted DLLs when using the 4.0-targeted proxy generation tools. If the problem is encountered in this situation, please make the above modifications to the <startup> element in the proxy generation tool’s app.config file.

A technical discussion of this exception and why it’s fixed by setting useLegacyV2RuntimeActivationPolicy=”true” can be found here.