5

I can't get SQLite Driver working in my sessionfactory.

I downloaded SQLite 1.0.48 from http://sqlite.phxsoftware.com/

I have added the references to System.Data.SQLite in my Tests project.

public static IPersistenceConfigurer GetSqlLiteConfigurer()
        {
            try
            {
                return SQLiteConfiguration
                .Standard
                .InMemory();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

This is how I generate the Configurer

The problem is when I build my sessionfactory I get the following error:

NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SQLite20Driver..ctor() 

I have tried to change of SQLite version but did not fix the issue.

I can't find what's the problem and I have been working on this for 2 days now.

Let me know if you need more information.

Thanks for the help!

Charles

Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57

5 Answers5

10

When I ran into this issue it was caused by running having my application's processor property set to anycpu and running on a 64bit system. To correct the issue I set my application processor property to x86. I don't think the System.Data.SQLite.dll supports running under a x64 process.

Aaron Fischer
  • 20,853
  • 18
  • 75
  • 116
7

I have fixed my problem by getting the System.Data.SQLite.dll file that is in the FluentNHibernate SVN Repository.

This is now working very well.

I should have checking this earlier ;)

Charles Ouellet
  • 6,338
  • 3
  • 41
  • 57
1

Check, if you are using 4.0 as your target framework. The ADO-driver currently (1.0.66) supports only 3.5.

Christian Waidner
  • 1,324
  • 1
  • 13
  • 22
0

This issue should be fixed with the lastest NuGet package from Microsoft.

PM> Install-Package SQLitePCL

https://www.nuget.org/packages/SQLitePCL/3.8.2

http://msopentech.com/blog/2014/02/03/new-open-source-portable-class-library-sqlite/

Eric
  • 354
  • 1
  • 3
  • 11
0

I am hitting the same problem on a build machine. It works fine when I open the project with Visual Studio, but when I run mstest.exe it fails with the above error. It also fails on my local development machine when I run by command line. Process Monitor shows no attempts to even locate the file by mstest.exe.

The build machine is 32-bit, my local machine is 64-bit. The assembly we are using is the one from the Fluent NHibernate trunk.

UPDATE: Figured it out - mstest.exe wasn't copying all of the assemblies when it was being run from the command line. I updated the localtestrun.config to include them under Deployment. Not sure why the behaviour is different from the IDE and command line test runner.

Colin Bowern
  • 2,152
  • 1
  • 20
  • 35
  • Hi there, I'm having the exact issue! My build machine is also 64-bit though, that's the only difference. My tests fail when run locally as well, via command line, but pass through from VS. How did you fix this please? What do you mean by "I updated the localtestrun.config to include them under Deployment" and how do I do that please? – iamserious Oct 21 '13 at 11:19
  • @iamserious if I recall not all of the required assemblies were being copied over. Using the deployment settings in your test run configuration you can ensure all the necessary bits are there for it to run. – Colin Bowern Oct 22 '13 at 18:55