Load Mixed-Mode dll from class library

1.9k views Asked by At

So i have a mixed-mode dll what i would like to load from my C# class library. But im getting this error:

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.

So i did some searching and figured out that i should add this to my app.config:

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>

But now there is the problem, since im trying to load that mixed mode dll from class library i dont have the app.config file.

How could i resolve this problem?

1

There are 1 answers

0
hs2d On BEST ANSWER

I found this blog post when googling:

http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/

It's exactly what i wanted and it works!