【问题标题】:FluentNhibernate and SQLiteFluentNhibernate 和 SQLite
【发布时间】:2009-05-10 15:05:40
【问题描述】:

我无法让 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 天。

如果您需要更多信息,请告诉我。

感谢您的帮助!

查尔斯

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • System.Data.SQLite.dll 可用于 x64,它只是另一个程序集(包含在 x64 目录中)
    • +1 这为我解决了这个问题(即使使用 SQLite 中的 x64 dll 似乎也不起作用)
    • 也为我工作,(在 vs 2010 的项目属性的构建选项卡上将平台目标更改为 x86)
    【解决方案2】:

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

    现在效果很好。

    我应该早点检查一下;)

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

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

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

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

        【讨论】:

        • 您好,我遇到了确切的问题!不过,我的构建机器也是 64 位的,这是唯一的区别。我的测试在本地运行时也会失败,通过命令行,但通过 VS。请问你是怎么解决这个问题的? “我更新了 localtestrun.config 以将它们包含在部署下”是什么意思,请问我该怎么做?
        • @iamserious 如果我记得不是所有必需的程序集都被复制了。使用测试运行配置中的部署设置,您可以确保它运行所需的所有必要位。
        【解决方案5】:

        应该使用 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/

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-10-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多