2011-10-01 50 views
1

我在使用NHibernate和SQLite的SharpDevelop中工作時遇到問題。我已經看到人們在Visual Studio 2010中使用.NET 4.0時遇到了確切的問題,但我在.NET 3.5中工作,並且我從未遇到過這些問題。NET 3.5中的NHibernate + SQLite問題

我做了一些單元測試,每當我試圖打開通過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一樣,我以前用過它。

任何人有任何想法?

這裏是我的規格BTW:

  • 的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

+0

您的SQLite DLL位於/ bin目錄(如果是web)或與.exe程序集相同的文件夾中?另外,無論如何,您的工作站是否在64位操作系統上?我相信SQLite在32位和64位操作系統上有不同的版本。 – LordHits

+0

實際上就是這樣。奇怪,但我不應該在我的測試項目中添加對SQLite的引用。但是在添加引用並確保它始終複製到其工作的bin目錄後。 – Maffelu

+0

說實話,我不知道如何將這篇文章轉換成答案,也不知道如何給你的評論+1,因爲它有幫助... – Maffelu

回答

1

確保您的SQLite DLL被複制到你的/ bin目錄。另外,需要警告的是,SQLite不是與操作系統無關的,並且有32位和64位兩種版本可供使用,並且在操作系統上使用適當的版本。 SQLite home