1
Vote

Testing an assembly built against 'v2.0.50727' of the runtime

description

I have a dll under test that would typlically use App.config from the exe that is using it. e.g. the app config has
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
This is because I am using System.Data.SQLite reference (runtime version 2.0.50727) in my assembly under test.

How this should be setup in the test dll so that the test pass.?

Right now I am not able to figure out a way to provide this so test fails:

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.

Have tried this approcah but not been successful
http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/

comments

meghma wrote Mar 20, 2015 at 8:48 PM

meghma wrote Mar 26, 2015 at 6:51 PM

    static SQLiteHelperTests()
    {
        bool policy = RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully;
    }
in the test class constructor resolved the issue