The mixed mode combination is built compared to the runtime version "2.0.50727" and cannot be loaded into runtime 4.0

I use Visual Studio 2012 and .Net Framework 4.5 I have 2 solutions: 1) WPF application 2) Class library (dll)

The class library contains 3 buttons and a control that must be inside the WindosFormsHost control since it was created for WinForms.

The only referenced assemblies outside the .NET Framework are for the aforementioned winforms and iTextSharp controls.

The winforms control seems old, and when I put the link in my dll, I got the same error as the header, but after other SO questions / answers, I put this in my configuration file:

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

Error:

The mixed mode assembly is built against the runtime version "v2.0.50727" and cannot be loaded into runtime 4.0 without additional configuration information

As I mentioned, I saw issues related to this problem, and they solved the problem in my DLL project, but in a project using this DLL, I tried all of them to no avail. For reference:

In this project, my configuration file has the same tags with the same values.

Also note that in my WPF application, at the beginning I received an error message that I could not find the specified DLL (for the winforms control), in the end I put this control DLL in the GAC.

I tried to change my target structure for all features (4.5, 4.0 and client, 3.5 full and client, 3.0 and 2.0), creating my DLL in debugging and release and setting “Generate serialization assembly” to OFF, also changed the platform’s goal from any processor to x86 and x64. I was just trying to change the value of one setting at a time.

Is this a problem in VS2012 or what do I need to do to solve this problem?

EDIT:

The above error is shown during development in the error list, the designer shows the error: "Unable to create an instance of" my_class "

The internal exception to this says: “Set connectionId threw an exception”, and the internal exception is the header message.

This still allows me to create a solution, and when I start the application, I get basically the same thing, except that the innermost exception says:

"Could not load file or assembly" SigPlusNET, Version = 1.1.3358.14336, Culture = neutral, PublicKeyToken = 6aef07010bb0624f "or one of its dependencies. An attempt was made to load a program with the wrong format."

This is one of the control builds of winForms. When checking through dotPeek, the only dependencies it has are the .NET Framework.

+6
source share
3 answers

Work with Bling for DirectX 10.0 (UI toolkit for Bling in CodePlex). I got an error that ended me here on this page, looking for a solution, the app.config file in D3D10.example included the supported version of runtime, version = 4. But it does NOT include a later line for the line version = 2..net, using app.config like:

 <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> <supportedRuntime version="v2.0.50727" /> </startup> </configuration> 

solved the problem, and all examples are executed in VS2012 after changing the configuration file to the code shown.

I do not know if this post will be late for an answer, I am just starting on Windows 7 and VS2012 this month in a graphic project, and a configuration change solved my problem.

+4
source

This could be because you have 4.0 in 1 place and 4.5 in another on this line:

 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 

Try:

 <supportedRuntime version="v4.5" sku=".NETFramework,Version=v4.5" /> 

or

 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> 
+2
source

My approach was a little different. The error clearly indicates that the .NET 2.0.50727 component was included in .NET 4.0 in the App.config file instead:

 <startup useLegacyV2RuntimeActivationPolicy="true"> 

He solved my problem

+2
source

All Articles