FluentNhibernate和SQLite

时间:2009-05-10 15:05:40

标签: unit-testing nhibernate sqlite fluent-nhibernate system.data.sqlite

我无法在sessionfactory中使用SQLite驱动程序。

我从http://sqlite.phxsoftware.com/

下载了SQLite 1.0.48

我在Tests项目中添加了对System.Data.SQLite的引用。

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

这是我生成配置器

的方法

问题是当我构建我的sessionfactory时出现以下错误:

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() 

我试图更改SQLite版本,但没有解决问题。

我找不到问题所在,我现在已经做了2天了。

如果您需要更多信息,请与我们联系。

感谢您的帮助!

查尔斯

5 个答案:

答案 0 :(得分:10)

当我遇到这个问题时,它是由于我的应用程序的处理器属性设置为anycpu并在64位系统上运行而引起的。要解决此问题,我将应用程序处理器属性设置为x86。 我不认为System.Data.SQLite.dll支持在x64进程下运行。

答案 1 :(得分:7)

我通过获取FluentNHibernate SVN存储库中的System.Data.SQLite.dll文件解决了我的问题。

现在效果很好。

我应该先检查一下;)

答案 2 :(得分:1)

检查,如果您使用4.0作为目标框架。目前ADO驱动程序(1.0.66)仅支持3.5。

答案 3 :(得分:0)

我在构建机器上遇到了同样的问题。当我使用Visual Studio打开项目时,它工作正常,但是当我运行mstest.exe时,它失败并出现上述错误。当我通过命令行运行时,它在我的本地开发机器上也失败了。进程监视器显示甚至没有尝试通过mstest.exe找到该文件。

构建机器是32位,我的本地机器是64位。我们使用的组件是来自Fluent NHibernate主干的组件。

更新:想出来 - mstest.exe在从命令行运行时没有复制所有程序集。我更新了localtestrun.config以将它们包含在Deployment下。不确定为什么行为与IDE和命令行测试运行器不同。

答案 4 :(得分:0)

应该使用Microsoft提供的最新NuGet软件包解决此问题。

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/