【问题标题】:NHibernate + SQLite issues in .NET 3.5.NET 3.5 中的 NHibernate + SQLite 问题
【发布时间】:2011-10-01 14:55:04
【问题描述】:

我在使用 NHibernate 和 SQLite 在 SharpDevelop 中工作时遇到问题。我看到有人在使用 .NET 4.0 的 Visual Studio 2010 中遇到了我的确切问题,但我使用的是 .NET 3.5,而且我之前从未遇到过这些问题。

我正在做一些单元测试,每当我尝试通过 NHibernate 打开与数据库的连接时,都会引发以下异常:

SetUp : StructureMap.StructureMapException : StructureMap Exception Code:  207
Internal exception while creating Instance '55c9fa8e-fa79-4698-8d06-7e305e73ac49' of PluginType SimplEconomics.Data.NHibernate.UnitOfWork.INHibernateUnitOfWork.  Check the inner exception for more details.
      ----> FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.


  ----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
  ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> 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. - d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:93

我认为这是最具体的最后一行,奇怪的是我第一次在 .NET 4.0 中创建我的项目(使用最新版本的 Sharpdevelop,4)并且我可以理解存在一些问题最新的 SQLite 版本,但这是 .NET 3.5,我以前用过。

有人有什么想法吗?

顺便说一句,这是我的规范:

  • SharpDevelop 3.2.1
  • SQLite 1.0.74.0
  • NHibernate 2.1.2.4000
  • .NET 4.0 安装,3.5
  • Windows Vista(如果重要)

这让我彻底疯了......

编辑: 我应该补充一点,我尝试了以下解决方案但没有成功: A similar stackoverflow-thread

【问题讨论】:

  • 您的 SQLite DLL 是位于 /bin 目录(如果是 Web)还是与 .exe 程序集位于同一文件夹中?另外,您的工作站是否在 64 位操作系统上?我相信 SQLite 对于 32 位和 64 位操作系统有不同的版本。
  • 实际上就是这样。奇怪的是,我不应该在我的测试项目中添加对 SQLite 的引用。但是在添加一个引用并确保它总是被复制到它工作的 bin 目录之后。
  • 说实话,我不知道如何将这篇文章转换为答案,也不知道如何为您的评论 +1,因为它有帮助...

标签: c# nhibernate sqlite fluent-nhibernate


【解决方案1】:

确保您的 SQLite DLL 已复制到您的 /bin 目录。另外,请注意,SQLite 与 Win OS 无关,并且有 32 位和 64 位版本可用,并在使用它的操作系统上使用适当的版本。 SQLite home.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-21
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    • 1970-01-01
    • 2012-01-22
    相关资源
    最近更新 更多