App.Config configuration startup in mixed mode .NET runtime version

If an application or DLL is compiled to in a .NET runtime vresion and references another DLL which is in another .NET runtime version, then it may cause an exception stating that the application is unabled to load DLL in mixed runtime mode.

The solution is to have an app.config file (athough I think there must also be a way without it) in the same directory as the executable and have this lines in it under in the XML hierarchy:

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

The key here is “useLegacyV2RuntimeActivationPolicy”. Look up the latest values to suit your runtime versions.