BadImageFormatException调试网站中的x64模式下运行 [英] BadImageFormatException debugging web site running in x64 mode

查看:166
本文介绍了BadImageFormatException调试网站中的x64模式下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多在这个论坛有关问题 BadImageFormatException ,但没有相当符合我的问题。

我有一个包含多个项目的解决方案。当我在调试或发行+任何CPU上运行,一切正常。当我切换到64位,但是,运行我的ASP.NET MVC项目,我得到了臭名昭著的 BadImageFormatException


  

无法加载文件或程序集AgileEFLib或它的一个依赖。试图加载程序格式不正确。


AgileEFLib是一个内部工具库,所以我必须与大量的灵活性。但真正奇怪的是,当我运行控制台应用程序,也对 AgileEFLib 的依赖,它完美的作品。失败的唯一情况是,当我运行的网站。

我已签,在发行的所有项目| 64配置设置来编译为64

还有什么能做些什么来解决这个?

编辑:另一个有价值的信息位的是,当我使用Visual Studio的IIS防爆preSS调试此问题只发生。当我发布和部署到IIS,它工作正常。

编辑:更多细节错误:

 在'/'应用程序的服务器错误。
-------------------------------------------------- ------------------------------无法加载文件或程序集AgileEFLib或它的一个依赖。试图加载程序格式不正确。
  说明:执行当前Web请求的执行过程中发生未处理的异常。请查看有关错误的详细信息的堆栈跟踪以及它起源于code。 异常详细信息:System.BadImageFormatException:未能加载文件或程序集AgileEFLib或它的一个依赖。试图加载程序格式不正确。源错误:
 当前Web请求的执行过程中生成了未处理的异常。有关异常的来源和位置信息可以使用异常堆栈跟踪下面确定。程序集加载跟踪:下列信息有助于确定程序集AgileEFLib无法加载。=== pre-绑定状态信息===
日志:显示名称= AgileEFLib
 (部分)
警告:部分绑定信息是为组装供应:
警告:程序集名称:AgileEFLib |域ID:3
警告:如果仅提供集显示名称的一部分发生了一个部分绑定。
警告:这可能导致粘合剂加载了不正确的装配。
警告:建议为大会提供了一个完全指定的文字标识,
警告:一个由简单的名称,版本,区域性和公钥令牌。
警告:请参阅白皮书http://go.microsoft.com/fwlink/?LinkId=109270以获取更多信息和应对这一问题的共同解决方案。
日志:应用平台=文件:/// C:/ src目录/ MyProject的/
LOG:初始PrivatePath = C:\\ SRC \\ MyProject的\\ BIN
调用汇编:(未知)。
===
日志:此绑定的默认加载上下文开始。
日志:正在使用应用程序配置文件:C:\\ SRC \\ MyProject的\\ web.config中
日志:使用主机配置文件:C:\\用户\\沙乌尔\\文档\\ IISEx preSS \\设置\\ aspnet.config
日志:从C使用计算机配置文件:\\ WINDOWS \\ Microsoft.NET \\框架\\ v4.0.30319 \\ CONFIG \\ machine.config中。
日志:没有被应用政策在这个时候(私人,自定义,局部的,或基于位置的程序集绑定)来引用。
日志:新的URL文件试图下载:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET文件/根/ 15406131 / a0c36da / AgileEFLib.DLL。
日志:新的URL文件试图下载:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET文件/根/ 15406131 / a0c36da / AgileEFLib / AgileEFLib.DLL。
日志:新的URL文件试图下载:/// C:/src/MyProject/bin/AgileEFLib.DLL。
错误:未能完成组装(HR = 0x8007000b)的设置。探测终止。


解决方案

试着遵循<一个指令href=\"http://blogs.msdn.com/b/rob/archive/2013/11/14/debugging-vs2013-websites-using-64-bit-iis-ex$p$pss.aspx\">Debugging VS2013网站使用64位IIS防爆preSS :


  

如果您正在使用的Visual Studio 2013的ASP.NET MVC网站
  (VS2013),你需要做一个注册表更改,如果你想运行IIS
  防爆preSS作为默认情况下,64位进程。使用的方法之一,
  下文。


  
  

命令行:


  
  

REG ADD HKEY_CURRENT_USER \\软件\\微软\\ VisualStudio的\\ 12.0 \\ WebProjects / V Use64BitIISEx preSS /吨REG_DWORD / d的1


There are a lot of questions on this forum about the BadImageFormatException, but none quite matches my issue.

I have a solution containing several projects. When I run in Debug or Release + Any CPU, everything works fine. When I switch to x64, however, and run my ASP.NET MVC project, I get the infamous 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.

AgileEFLib is an in-house utility library, so I have plenty flexibility with that. But the really weird thing is that when I run a console app that also has a dependency on AgileEFLib, it works perfectly. The only time it fails is when I run the web site.

I have checked that all projects in the Release|x64 configuration are set to compile as x64.

What else can I do to troubleshoot this?

EDIT: Another useful bit of information is that this problem only occurs when I'm debugging using Visual Studio's IIS Express. When I publish and deploy to IIS, it works fine.

EDIT: more details about the error:

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.

解决方案

Try to follow the instructions from Debugging VS2013 Websites Using 64-bit IIS Express:

If you are working on ASP.NET MVC web sites in Visual Studio 2013 (VS2013), you need to make one registry change if you want to run IIS Express as a 64-bit process by default. Use one of the methods, below.

Command-Line:

reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1

这篇关于BadImageFormatException调试网站中的x64模式下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆