I have a project in which I'd like to use some of the .NET 4.0 features but a core requirement is that I can use the System.Data.SQLite framework which is compiled against 2.X. I see mention of this being possible such as the accepted answer here but I don't see how to actually achieve this.
When I just try and run my 4.0 project while referencing the 2.X assembly I get:
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.
What "additional configuration" is necessary?
Depending on what version of the framework you're targetting, you may want to look here to get the correct string:
http://msdn.microsoft.com/en-us/library/ee517334.aspx
I wasted hours trying to figure out why my release targetting .Net 4.0 client required the full version. I used this in the end:
I found a way around this after 3-4 hours of googling. I have added the following
If this doesn't solve your problem then--> In the Project References
Right Click on DLL
where you getting error -->Select Properties
-->Check the Run-time Version
--> If it isv2.0.50727
then we know the problem. The Problem is :- you are having2.0 Version of respective DLL.
Solution is:- You candelete the respective DLL
from the Project references and thendownload the latest version of DLL's
from the corresponding website and add the reference of the latest version DLL reference then it will work.Add following at this location C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64 FileName: sgen.exe.config(If you dont find this file, create and add one)
Doing this resolved the issue
Was able to solve the issue by adding "startup" element with "useLegacyV2RuntimeActivationPolicy" attribute set.
But had to place it as the first child element of configuration tag in App.config for it to take effect.
I ran into this issue when we changed to Visual Studio 2015. None of the above answers worked for us. In the end we got it working by adding the following config file to ALL sgen.exe executables on the machine
Particularly in this location, even when we were targeting .NET 4.0:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools
Once you set the app.config file, visual studio will generate a copy in the bin folder named App.exe.config. Copy this to the application directory during deployment. Sounds obvious but surprisingly a lot of people miss this step. WinForms developers are not used to config files :).