user472875
user472875

Reputation: 3175

Visual Studio adding DLL as reference error

I'm adding a library to a project, and I get the following 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.

I'm not too sure about what I have to tweak in order fro this to run. Anyone know what the changes should be?

Thanks,

PM

Upvotes: 2

Views: 1745

Answers (3)

Marc Gravell
Marc Gravell

Reputation: 1062492

Untested, but maybe (from MSDN)

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

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1499760

As Marc says, ideally you'd rebuild in .NET 4, or make your project target .NET 3.5 or lower. Mixed-mode assemblies built for the v2 CLR use "legacy" runtime activation techniques which don't work well with the v4 CLR's ability to run multiple CLRs in the same process.

Alternatively, you can add this information to your app.config:

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

See this question, this documentation and this blog post for details.

Upvotes: 2

SpeksETC
SpeksETC

Reputation: 1013

I agree that stackoverflow is amazing, but google still does have a place in the world...

From copying and pasting your error into google: http://social.msdn.microsoft.com/Forums/en/clr/thread/58271e39-beca-49ac-90f9-e116fa3dd3c0

Good luck.

Upvotes: 0

Related Questions