I am running into a weird issue with my managed C++ assembly. Even though I have the C# project and the managed C++ (DLL) project set to target .NET 3.5, when I compile the managed assembly its "Runtime Version" is 2.0.
I am trying to use the same assembly across a .NET 3.5 project and a .NET 4.0 version of a CSScript and the CSScript refuses to run with a .NET 2.0 assembly ("Runtime Exception: 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 managed to localize the problem to the following (all work done in VS 2008):
When you look at the properties of the reference in the C# project you will see the "Runtime Version" is v2.0.50727. My question is, what the hell?
Why is the runtime version 2.0? I set everything to 3.5 ... How can I force the managed C++ project to compile against .NET 3.5?
Thanks, Marek
The runtime version refers to the version of the virtual machine, not the .NET class libraries. .NET 3.5 runs on the same virtual machine as .NET 2.0, that's why your reference shows v2.0.50727. If you want to see if the C++ project is actually targeting the 3.5 version of the framework, you should check the individual library references in that project.
Your "fix" won't actually fix the problem.
Runtime Exception: 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
You need to use the 4.0 runtime to avoid this, no point in even trying for some mythical "3.5" version. For that, you need to compile using the VC++ 2010 compiler. Since you need to use it in a .NET 3.5 application, that's a non-starter.
Try looking into that "additional configuration information". See this question and also this one .
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.