SQLite NHibernate configuration with .Net 4.0 and vs 2010
- Sure. You can also use previous versions if you configure mixed mode loading.
- No need to be in the GAC. You can use gacutil to remove the assemblies from the GAC.
- Use the x64 DLL to target Windows x64 and x86 for Windows x86
- Please post the full exception stack trace. Also if you're using a 3.5 assembly use mixed mode loading.
- FNH has no reference to SQLite.
I want this to stand out so it will help someone else; the full reason this happens is explained here; so adjust your congig to use BOTH the redirect there in combo with the mixed loading mode referenced here by Mauricio.
I had the same problem, and found little or no help on all the forum and blog posts.
Note that this problem is specific to a case respecting all of the following criteria:- using SQLite- with System.Data.SqlLite- on an x64 machine- and NHibernate (2.1.2.4 in my case)
That chunk of config in my web.config (or app.config for my unit tests) got it to work. I had to qualify the assembly to be sure he loads correctly.
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <qualifyAssembly partialName="System.Data.SQLite" fullName="System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64" /> </assemblyBinding> </runtime></configuration>
Somewhere in it's inner plumbing, during the mapping using scanned assemblies, NHibernate creates an Assembly object using it's paritla name, as a string, "System.Data.SQLite". Somehow, the x86 version of the assembly got loaded.
The above configuration made sure that using the partial name to load an assembly would provide the x64 version.
EDIT: I use version 1.0.66.0 and took the DLL under the bin\x64 folder in the file SQLite-1.0.66.0-binaries.zip available on sourceforge here.