1
votes

Running Nh 3.2 using SQLite throws the following exception:

---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.2.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.

I use the latest (net 4 compatible) version of SQlite: version 1.0.74.0. I have added the following to my config:

.Database(SQLiteConfiguration.Standard.InMemory().Raw("hbm2ddl.keywords", "none").ShowSql())

I, also added in the config file:

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0"/>
</startup>

The weird thing is that first it worked. And now I get the above error.

3

3 Answers

11
votes

I fixed the issue using the solution provide above (thanks), but also figured out that by using nuget you can simply install System.data.sqlite straight to your project via the package manager, and you dont need any of the web.config settings.

Install-Package System.Data.Sqlite.x86
1
votes

You probably know this, but just in case. Latest version of SQLite for .NET is distributed as 2 dlls.

  • System.Data.SQLite.dll
  • SQLite.Interop.dll

Both dlls need to be present in the same folder as your EXE. Interop dll is platform specific so you have to manually (or Post-build) copy x86 or x64 version. One thing to keep in mind is that SQLite.Interop.dll depends on MSVCR100.DLL. This is part of Visual C++ 2010 SP1 Redistributable Package, you need to make sure that you have it. Please see this answer.

Also in the web environment you might need this configuration:

<system.data>
    <DbProviderFactories>
        <remove invariant="System.Data.SQLite"/>
        <add 
          name="SQLite Data Provider" 
          invariant="System.Data.SQLite" 
          description=".Net Framework Data Provider for SQLite" 
          type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
    </DbProviderFactories>
</system.data>
0
votes

use the version that came with fluentnhibernate binaries 1.0.60.0