What can lead to the fact that the version of the assembly and the version of the performance will be different?

I have a C # solution, two projects, winforms and dll, where the winforms project refers to a DLL, and I installed everything I know in the project in version 2.0, but I still get this FileLoadException on startup:

The mixed-mode compilation is built against the runtime version 'v2.0.50727' and cannot be loaded at 4.0 time without additional configuration information.

Settings I configured:

  • Properties The target structure is the .NET framework 2.0.
  • All links referenced by project links are built with .NET 2.0
  • All flags in the configuration manager indicating whether projects should be created will be checked.

I also tried to clear the solution by deleting the \ bin \ map project, but when the solution is recompiled and launched, an exception is still thrown. On my machine, I have Visual Studio 2010 Ultimate with .NET 4.0 and .NET 3.5 SP1 installed.

I must have skipped the setting that throws this exception, but I don't know about it, does anyone know? I just want it to use .NET 2.0, not .NET 4.0.

+4
source share
2 answers

To try to load it into CLR 2.x, you may need (in your app.config file):

<configuration> <startup> <supportedRuntime version="v2.0.50727"/> </startup> </configuration> 

This is usually only required in mixed mode and forces the bootloader's hand.

+4
source

Well, it works with 4.0 CLR, despite your efforts to configure 2.0. This is due to the C ++ / CLI assembly, presumably with the DLL you referenced. The .config file is needed to convince the CLR that it is normal to use .NET 4.0 to load this DLL, although it may contain unmanaged code that expects to use 2.0, google "useLegacyV2RuntimeActivationPolicy". This will solve the loading 4.0 problem for this DLL.

The only reason he could download 4.0 is the .config file, which says that it should use the 4.0 element, <supportedRuntime> . To make this more visual, you can use the Fuslogvw.exe tool, configure it to register all the bindings. Copy / paste the binding trace for the exe into your question if you cannot figure it out.

+1
source

Source: https://habr.com/ru/post/1335231/


All Articles