问题
I have a tests project that I am trying to test my nhibernate layer with using sql lite in-memory database.
I'm getting the error:
Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.1.0.4000,
private void CreateSessionFactory()
{
_sessionFactory = Fluently
.Configure()
.Database(_dbType)
.Mappings(m => m.FluentMappings
.AddFromAssemblyOf<UserMap>())
.ExposeConfiguration(cfg => _configuration = cfg)
.BuildSessionFactory();
}
I'm using fluentnhibernate, and nunit also.
What could the issue be?
Update
I downloaded the x64 (i'm on windows 7 64-bit) from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and now I'm getting this error:
Unable to load DLL 'SQLite.Interop.DLL': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
If I try and add the Interop.dll in vs.net 2010, it doesn't let me saying it could not be added, make sure it is valid etc.
回答1:
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.
Another thing to keep in mind is that SQLite.Interop.dll itslef depends on MSVCR100.DLL (part of Visual C++ 2010 SP1 Redistributable Package). You can get it here:
- 64 bit version
- 32 bit version
来源:https://stackoverflow.com/questions/7493840/could-not-create-the-driver-from-nhibernate-driver-sqlite20driver-nhibernate-v