这个论坛里有很多关于这个的问题BadImageFormatException
,但没有一个完全符合我的问题。
我有一个包含多个项目的解决方案。当我在“调试”或“发布”+任何 CPU 中运行时,一切正常。然而,当我切换到 x64 并运行我的 ASP.NET MVC 项目时,我遇到了臭名昭著的问题BadImageFormatException
无法加载文件或程序集“AgileEFLib”或其依赖项之一。尝试加载格式不正确的程序。
AgileEFLib 是一个内部实用程序库,因此我对此有很大的灵活性。但真正奇怪的是,当我运行一个控制台应用程序时,它也依赖于AgileEFLib
,它工作完美。唯一一次失败是当我运行网站时。
我已经检查过 Release|x64 配置中的所有项目都设置为编译为 x64。
我还能做什么来解决这个问题?
EDIT:另一个有用的信息是,此问题仅在我使用 Visual Studio 的 IIS Express 进行调试时才会出现。当我发布并部署到 IIS 时,它工作正常。
编辑:有关错误的更多详细信息:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'AgileEFLib' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'AgileEFLib' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'AgileEFLib' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = AgileEFLib
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: AgileEFLib | Domain ID: 3
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:/src/MyProject/
LOG: Initial PrivatePath = C:\src\MyProject\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\src\MyProject\web.config
LOG: Using host configuration file: C:\Users\Shaul\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:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/15406131/a0c36da/AgileEFLib.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/15406131/a0c36da/AgileEFLib/AgileEFLib.DLL.
LOG: Attempting download of new URL file:///C:/src/MyProject/bin/AgileEFLib.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
尝试按照以下说明进行操作使用 64 位 IIS Express 调试 VS2013 网站:
如果您正在 Visual Studio 2013 中处理 ASP.NET MVC 网站
(VS2013),如果要运行 IIS,则需要更改一项注册表
默认情况下表示为 64 位进程。使用其中一种方法,
以下。
命令行:
reg 添加 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)