11 Vote

C# Error Message: .NET 2.0 DLL in .NET 4.0 cannot be loaded in the 4.0 runtime without additional configuration information

Question by Guest | Last update on 2021-06-13 | Created on 2012-12-27

I have a DLL that was developed in the Dot Net version 2.0 and I would like to reference to it in .Net Framework 4.0.

However, this leads to the following error:

Cannot intercept exception. Debugged program can not be continued and
properties can not be evaluated.
System.IO.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.

There is mentioned "additional configuration information", ie any additional configurations that must obviously be made to use the DLL.

Can someone tell me, what kind of settings or parameters I have to set?

ReplyPositiveNegativeDateVotes
2Best Answer2 Votes

Your DLL is a CLR 2.0 mixed mode assembly. To use these, you need to add to your app.config file of your project the line <startup useLegacyV2RuntimeActivationPolicy="true" />, so that your app.config looks like this, for example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <startup useLegacyV2RuntimeActivationPolicy="true" />    
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
</configuration>

Thereby you are telling the CLR, which version it should use to load your DLL. However, this does not apply to managed assemblies. So, a CLR 2.0 managed assembly can be loaded even without this line.
Last update on 2021-06-13 | Created on 2012-12-27

ReplyPositive Negative
00 Votes

I have added these lines in app.config but its not working. I am using sqlite dll with visual studio 2010.
2013-06-12 at 07:22

ReplyPositive Negative
11 Vote

Are you using the SQLite DLL provided especially for .NET? On the SQLite Download Page, there is a section "Precompiled Binaries for .NET". I think this should work for you.
2013-06-13 at 01:15

Positive Negative
Reply
00 Votes

Hello,

I have already changed in App.Config file like this

<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">

<supportedruntime version="v4.0" 
            sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

and target framework also changed. But I got an exception while i was executing the database script with ExecuteNonQuery method.

"system io fileloadexception mixed mode is built 
against version 2.0"

Any Idea about the problem?

Thanks in advance.
2014-03-10 at 13:24

ReplyPositive Negative
Reply

Related Topics

VirtualBox: Change Date and Time

Tutorial | 10 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.