3

問題:MVC3應用程序 - 獲取「無法加載文件或程序集」System.Data.SQLite「或它的一個依賴關係。」

我正在構建一個C#4.0,基於MVC 3的Web應用程序。我使用SQLite作爲數據庫。

當我啓動應用程序,我得到這個錯誤:

無法加載文件或程序集「System.Data.SQLite」或它的一個依賴。試圖加載格式不正確的程序。

這是融合的組件負載跟蹤:

=== Pre-bind state information === 
LOG: User = Steve-PC\Steve 
LOG: DisplayName = System.Data.SQLite 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: System.Data.SQLite | Domain ID: 2 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///C:/Users/Steve/Documents/Visual Studio 2010/Projects/EMMA3/EMMA_Web/ 
LOG: Initial PrivatePath = C:\Users\Steve\Documents\Visual Studio 2010\Projects\EMMA3\EMMA_Web\bin 
Calling assembly : (Unknown). 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Users\Steve\Documents\Visual Studio 2010\Projects\EMMA3\EMMA_Web\web.config 
LOG: Using host configuration file: C:\Users\Steve\Documents\IISExpress\config\aspnet.config 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///C:/Users/Steve/AppData/Local/Temp/Temporary ASP.NET Files/root/6454c2d1/d37faccb/System.Data.SQLite.DLL. 
LOG: Attempting download of new URL file:///C:/Users/Steve/AppData/Local/Temp/Temporary ASP.NET  Files/root/6454c2d1/d37faccb/System.Data.SQLite/System.Data.SQLite.DLL. 
LOG: Attempting download of new URL file:///C:/Users/Steve/Documents/Visual Studio 2010/Projects/EMMA3/EMMA_Web/bin/System.Data.SQLite.DLL. 
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated. 

我使用:

Windows 7的64位 的Visual Web Developer 2010 IIS 7.5快遞 System.Data.SQLite 64 1.0。 77.0

我已經搜索了很多,一般認爲這與在64位上運行32位程序集有關係統或反之亦然。

事情我已經嘗試:

  1. 切換到IIS快遞從VS內置的Web服務器。顯然,內置服務器只能處理32位應用程序,IIS Express可以同時處理這兩種應用程序。不用找了。
  2. 請確保您使用的是64位版本的SQLite。最初,我使用常規版本,但改爲64位版本似乎沒有幫助。
  3. 在IIS中啓用「win 64上的32位應用程序」設置。 (在IIS Express中,這是通過使用appcmd.exe - appcmd set apppool /apppool.name:「」/ enable32bitapponwin64:true)來完成的。再次,這沒有改變。
  4. 卸載/重新安裝Sqlite。不用找了。
  5. 創建一個簡單版本的項目,以確保一切都乾淨並縮小原因。這導致我在下面的'重現步驟',但並沒有真正幫助我。

重現步驟:

  1. 創建新的MVC 3 web項目。
  2. 運行它,看它是否工作。
  3. 使用Nuget添加對SQLite x64的引用。
  4. 再次運行網站,它會出現此錯誤。

所以總結 - 我得到上面的錯誤,它肯定是以某種方式歸因於SQLite,我似乎擁有一切64位,但它仍然無法正常工作。有任何想法嗎?

在此先感謝。

回答

1

前段時間發現了這一點,並忘記了這個問題。

答案是刪除SQLite x64並安裝SQLite x86 ...就這麼簡單。當我在64位版本的Windows上構建64位程序集時,似乎很奇怪,但我們離開了。 實際上擁有數據訪問邏輯的類庫仍然引用64位版本的SQLite,但由於某些原因,實際的Web項目必須引用32位版本。

1

如果嘗試從VisualStudio內運行Web應用程序時出現此錯誤,那是因爲內置Web服務器僅爲32位。如果您希望在VisualStudio中使用64位進行調試/運行,請查看Cassini項目。有指示構建一個64位版本的cassini,並使用它來代替VisualStudio默認的Web服務器。

相關問題