简体   繁体   中英

Mixed Mode C++/CLI System.IO.FileLoadException

My solution contains 2 projects.

First project is a C++ Win32 Application and the second project is a C# library that manages 2 other C# libraries that was not built by me. The idea behind this was to build a C# library that handles these other 2 C# libraries.

Now, these 2 C# libraries was built for .NET 3.5 and I have set up my C# project to be built for .NET 3.5 aswell.

I created a C++ Wrapper, which works quite well. The problem appears when trying to create a object of a class that my C# library gets from one of the other 2 libaries.

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.

Now, I have been looking over a dozen posts where this issue has been posted. None of them solved my issue. I have tried several different config files for my executable(my C++ project), aswell as for my C# library.

I have tried

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

And several other ones alike.

It seems that in your project you have some v2.0.50727 dlls. Try this:

edit your App.config file and add:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM