5

我无法让 SQLite 驱动程序在我的 sessionfactory 中工作。

我从http://sqlite.phxsoftware.com/下载了 SQLite 1.0.48

我在我的测试项目中添加了对 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 天。

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

谢谢您的帮助!

查尔斯

4

5 回答 5

10

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

于 2009-06-02T14:48:05.380 回答
7

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

这现在工作得很好。

我应该早点检查一下;)

于 2009-05-10T15:11:32.320 回答
1

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

于 2010-11-20T17:57:30.317 回答
0

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

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

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

于 2009-06-03T13:08:45.980 回答
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/

于 2014-02-20T14:56:26.700 回答