.NET Framework 4.0 with builds using 2.0

I have a Windows Form project built into .NET 4.0. And this applies to the System.Data.SQLite DLL, which is built in .NET 2.0. When my exe file is deployed to my client, which only installs the .NET Framework 4.0 on its computer (Windows XP), exe fails.

How to get the EXE to load the specified DLL into CLR 4.0 (although it is built to use CLR 2.0), so that without installing the .NET Framework 2.0, it can still work?

+4
source share
3 answers

Set useLegacyV2RuntimeActivationPolicy to true in your app.config ( more ).

I have more information about SQLite on .NET 4 (especially with EF4) on my blog .

+4
source

John

I'm having trouble setting up SQLite, which I use with NHibernate, as opposed to EntityFramework (I think the latest version might have considered EF more, not sure). Here is what works for me now.

1) modify app.config as Stephen says, but also add a runtime directive for reasons in the comments below.

2) match your target build platform with the dll, which is first and foremost suitable for your needs. Either 64x or 86x will work, but AnyCpu gets some kind of explicit exception. I am reluctant to use x86 because it is safer and does not have a noticeable effect on what I do with it.

At some point, you may find it useful to make separate projects to isolate dependency problems in the latest version (I think it was April). Do not expect much with any kind of WPF through Visual Studio, as the XAML designer just won't like it. It's quick and nice as soon as you get it, but the latest release is not a problem.

NTN
Berryl

add-ons to supplement apps

 <!-- SQLite requires this mixed mode load setting--> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup> <runtime> <loadFromRemoteSources enabled="true"/> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <!-- SQLite is built with older System.Data so we need this redirect --> <dependentAssembly> <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089"/> <bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> 
+1
source

Install .Net 4 for the full profile, see here msdn.microsoft.com/en-us/library/cc656912.aspx

Right-click Project> Proeprties> Compile tab> Advanced Compile Options> Target Framework. Make sure it is not installed in .Net Client> installed for it .Net 4 (full)

Edit: The .NET Framework is backward compatible in general, and you can configure supported Runtimes, see here http://social.msdn.microsoft.com/forums/en-US/clr/thread/de5956f6-7a12-45d8- ae03-988ad8434a17

Regarding the crash EXE, I assume this is the second exception (that is, that handles the debugger handle), so you might want to take a memory dump and use WinDBG! Analyze the memory dump and find out the exact cause, if, of course, the second random exception message does not display System.Data.SQLite as a DLL problem.

0
source

All Articles