問題:
私は ac# 4.0、MVC 3 ベースの Web アプリを構築しています。データベースとして SQLite を使用しています。
アプリを起動すると、次のエラーが表示されます。
ファイルまたはアセンブリ 'System.Data.SQLite' またはその依存関係の 1 つを読み込めませんでした。不正な形式のプログラムをロードしようとしました。
これは Fusion アセンブリのロード トレースです。
=== 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 x64 Visual Web Developer 2010 IIS Express 7.5 System.Data.SQLite x64 1.0.77.0
私は多くのことをグーグルで調べましたが、一般的な考えは、これは 64 ビット システムで 32 ビット アセンブリを実行すること、またはその逆に関連しているようです。
私が試したこと:
- VS 組み込み Web サーバーから IIS Express に切り替えます。どうやら、ビルトイン サーバーは 32 ビット アプリケーションにしか対応できず、IIS Express は両方に対応できるようです。変化なし。
- 64 ビット バージョンの SQLite を使用していることを確認してください。元々は通常版を使っていたのですが、64bit版に変えても改善されないようです。
- IIS で「win 64 の 32 ビット アプリ」設定を有効にします。(IIS エクスプレスでは、これは appcmd.exe - appcmd set apppool /apppool.name: "" /enable32bitapponwin64:true を使用して行われます)。繰り返しますが、これは変更を加えませんでした。
- Sqlite をアンインストール/再インストールします。変化なし。
- プロジェクトのより単純なバージョンを作成して、すべてがクリーンであることを確認し、原因を絞り込みます。これにより、以下の「再現手順」に進みましたが、実際には役に立ちませんでした。
再現する手順:
- 新しい MVC 3 Web プロジェクトを作成します。
- 実行して、動作することを確認します。
- Nuget を使用して、SQLite x64 への参照を追加します。
- サイトを再度実行すると、このエラーが発生します。
要約すると、上記のエラーが発生しています。これは間違いなく SQLite が原因です。すべてが 64 ビットのようですが、それでも機能しません。何か案は?
前もって感謝します。