问题:
我正在构建基于 ac# 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 x64
可视化 Web 开发人员 2010
IIS Express 7.5
System.Data.SQLite x64 1.0.77.0
我在 Google 上搜索了很多,普遍的想法似乎是这与在 64 位系统上运行 32 位程序集有关,反之亦然。
我尝试过的事情:
- 从VS内置的Web服务器切换到IIS Express。显然,内置服务器只能处理 32 位应用程序,而 IIS Express 可以两者兼而有之。没有变化。
- 确保您使用的是 64 位版本的 SQLite。最初我使用的是普通版本,但更改为 64 位版本似乎没有帮助。
- 在 IIS 中启用“win 64 上的 32 位应用程序”设置。 (在 IIS Express 中,这是使用 appcmd.exe - appcmd set apppool /apppool.name: "" /enable32bitapponwin64:true 完成的)。同样,这没有改变。
- 卸载/重新安装 Sqlite。没有变化。
- 创建一个更简单的项目版本,以确保一切都干净并缩小原因范围。这引导我进入下面的“重现步骤”,但并没有真正帮助我。
重现步骤:
- 创建新的 MVC 3 Web 项目。
- 运行它并查看它是否有效。
- 使用 Nuget 添加对 SQLite x64 的引用。
- 再次运行站点,就会出现这个错误。
总而言之 - 我收到上面的错误,这肯定是由于 SQLite 在某种程度上造成的,我似乎拥有 64 位的所有内容,但它仍然无法工作。有什么想法吗?
提前致谢。
The problem:
I'm building a c# 4.0, MVC 3 based web app. I'm using SQLite as a database.
When I start the app, I get this error:
Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.
This is the fusion assembly load trace:
=== 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.
I am using:
Windows 7 x64
Visual Web Developer 2010
IIS Express 7.5
System.Data.SQLite x64 1.0.77.0
I've Googled around a lot and the general thought seems to be that this is related to running a 32 bit assembly on a 64 bit system or vice versa.
Things I've tried:
- Switch to IIS Express from the VS built in web server. Apparently the built in server can only cope with 32bit applications and IIS Express can do both. No change.
- Make sure you're using the 64 bit version of SQLite. Originally, I was using the regular version but changing to the 64 bit version does not seem to help.
- Enable the '32 bit app on win 64' setting in IIS. (In IIS express, this is done using appcmd.exe - appcmd set apppool /apppool.name: "" /enable32bitapponwin64:true). Again, this made no change.
- Uninstall/reinstall Sqlite. No change.
- Create a simpler version of the project to make sure everything is clean and narrow down the cause. This lead me to the 'steps to reproduce' below but hasn't really helped me.
Steps to reproduce:
- Create new MVC 3 web project.
- Run it and see that it works.
- Use Nuget to add a reference to SQLite x64.
- Run site again and it will give this error.
So in summary - I'm getting the error above, it's definitely due in some way to SQLite, I seem to have everything 64 bit, but it still doesn't work. Any ideas?
Thanks in advance.
发布评论
评论(2)
前段时间想出来了,忘记了这个问题。
答案是删除 SQLite x64 并安装 SQLite x86...就这么简单。当我在 64 位版本的 Windows 上构建 64 位程序集时,这似乎很奇怪,但我们就这样了。
实际具有数据访问逻辑的类库仍然引用 SQLite 的 64 位版本,但由于某种原因,实际的 Web 项目必须引用 32 位版本。
Figured this out some time ago and forgot about this question.
The answer was to remove SQLite x64 and install SQLite x86... Simple as that. Seems weird when I'm building a 64 bit assembly on a 64 bit version of windows but there we go.
The class libraries that actually have the data access logic still reference the 64 bit version of SQLite but for some reason the actual web project has to reference the 32 bit version.
如果您在尝试从 VisualStudio 中运行 Web 应用程序时收到此错误,那么这是因为内置 Web 服务器仅为 32 位。如果您希望在 VisualStudio 中使用 64 位进行调试/运行,请查看 Cassini 项目。有说明构建 64 位版本的 cassini 并使用它代替 VisualStudio 默认 Web 服务器。
If you get this error when attempting to run the web application from within VisualStudio, then it is because the built-in webserver is 32-bit only. If you wish to debug / run with 64-bit from within VisualStudio, check out the Cassini project. There are instruction to build a 64-bit version of cassini and use it instead of the VisualStudio default web-server.