我使用的是最新的NHibernate 2.1.0Beta2.我正在尝试使用SQLite进行单元测试,并将配置设置为:
Dictionaryproperties = new Dictionary (); properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver"); properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect"); properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); properties.Add("query.substitutions", "true=1;false=0"); properties.Add("connection.connection_string", "Data Source=test.db;Version=3;New=True;"); properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu"); configuration = new Configuration(); configuration.SetProperties(properties);
当我尝试运行它时,我收到以下错误:
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, useelement in the application configuration file to specify the full name of the assembly. at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName) in c:\CSharp\NH\nhibernate\src\NHibernate\Driver\ReflectionBasedDriver.cs: line 26 at NHibernate.Driver.SQLite20Driver..ctor() in c:\CSharp\NH\nhibernate\src\NHibernate\Driver\SQLite20Driver.cs: line 28
所以看起来我需要直接引用程序集.我该怎么做才能让我不再犯这个错误?
我从这里下载了最新的程序集:http://sourceforge.net/projects/sqlite-dotnet2.
你在运行64位Windows吗?
浏览Google时,我看到几篇帖子评论说SQLite dll文件是为x86而不是x64构建的.
看到这篇文章:http://codetripper.wordpress.com/2009/01/03/using-sqlite-on-vista-64-bit/
编辑:我不知道什么时候,但我今天注意到最新版本System.Data.SQLite
包括x64 dll.x64 .dll在\bin\x64
.
http://sqlite.phxsoftware.com/
添加对System.Data.SQLite程序集的引用后,我不得不将copy local设置为true(在VS中选择程序集引用并转到属性),以便将程序集复制到bin目录.