Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 435 Vote(s) - 3.42 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What can cause assembly build version and runtime version to differ?

#1
I have a C# solution, two projects, a winforms and a dll, where the winforms project references to the dll, and I've set everything I know of in the project to the framework version 2.0, yet I still get this FileLoadException on startup:

> 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.

The settings I configured are:

- Properties - Target framework is .NET framework 2.0
- All references the project links to are built with .NET 2.0
- All checkboxes in the Configuration manager indicating whether the projects should be built are checked.

Also I've tried cleaning the solution, deleting the map project\bin\, but when the solution is recompiled and run, the exception is still thrown. On my machine I have Visual Studio 2010 Ultimate with both .NET 4.0 and .NET 3.5 SP1 installed.


I must have missed a setting which causes this exception, but I'm unaware of it, does anyone know ? I just want it to use .NET 2.0, not .NET 4.0.

Reply

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

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

This is generally only required when you have mixed-mode, and forces the hand of the loader.
Reply

#3
Well, it's running the 4.0 CLR in spite of your efforts to target 2.0. It's bitching about a C++/CLI assembly, presumably the DLL that you referenced. A .config file is required to convince the CLR that it is okay to use .NET 4.0 to load that DLL, even though it might contain unmanaged code that expects 2.0 to be used, google "useLegacyV2RuntimeActivationPolicy". That would solve the 4.0 loading problem for that DLL.

About the only other reason that it could still load 4.0 is a .config file that says it should use 4.0, `<supportedRuntime>` element. To make this more visual you can use the Fuslogvw.exe tool, set it up to log all bindings. Copy/paste the binding trace for your EXE into your question if you can't make sense of it.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through