【问题标题】:64-bit ASP.NET MVC App won't run64 位 ASP.NET MVC 应用程序无法运行
【发布时间】:2012-11-25 19:31:45
【问题描述】:

首先,我之前设法让我的一个 64 位测试网络应用程序在这台机器上运行(早在我为这个项目设计原型时)。我已经在 32 位上工作了几个星期,并意识到我需要将应用程序切换到 64 位,当我这样做(在项目中将目标平台设置为 x64)并重新部署时,它停止运行。

上次我花了几天时间才让 64 位工作,但我不确定这次我错过了什么。

我在 IIS 下发布和调试。

我收到带有以下消息的 BadImageFormatException:“无法加载文件或程序集 'GEMS.Web' 或其依赖项之一。尝试加载格式不正确的程序。”

此应用同时引用 64 位和 32 位程序集。我已在 IIS 的应用程序池中将“启用 32 位应用程序”设置为 true。

我使用的是 VS.NET 2012,IIS 7.5,在 64 位 Win 7 机器上运行。

以下来自程序集负载跟踪:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\SysWOW64\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = XXXXXX\xxxxxx
LOG: DisplayName = GEMS.Web
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: GEMS.Web | 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:/inetpub/wwwroot/GEMS.Web/
LOG: Initial PrivatePath = c:\inetpub\wwwroot\GEMS.Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\inetpub\wwwroot\GEMS.Web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\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/gems.web/eea5792e/72317e39/GEMS.Web.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/gems.web/eea5792e/72317e39/GEMS.Web/GEMS.Web.DLL.
LOG: Attempting download of new URL file:///c:/inetpub/wwwroot/GEMS.Web/bin/GEMS.Web.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

【问题讨论】:

    标签: asp.net-mvc iis 64-bit badimageformatexception


    【解决方案1】:

    如果您没有使用任何本机 Win32 库,您应该为您的程序集定位 Any CPU,并且不要混淆 IIS 中的启用 32 位应用程序 设置(将其设置为 false)。

    【讨论】:

    • 我不确定你的意思。我的应用程序必须是 64 位的,因为我引用的是 64 位程序集。如果我将它设置为任何 CPU,那么当我点击加载那些 64 位程序集的代码时,它们将无法加载。
    • 您可以控制这些程序集吗?如果是,那么也将它们更改为 Any CPU。如果没有,请联系这些程序集的作者,并要求他为您提供它们的 CPU 位数不可知版本(任何 CPU)。
    • 不,我无法控制 Crystal Reports 程序集。我必须使用 64 位 Crystal,因为如果我使用 32 位版本的 Crystal,我会遇到这个问题:stackoverflow.com/questions/4208516/… 现在,通过使用可用的 32 位 log4net.dll 的特定版本来解决这个问题来自 SAP,但是这与 Castle 中的 log4net 引用冲突。之前打过这场仗,上次让 64 位的东西工作是更简单的解决方案。
    【解决方案2】:

    使用以下方法更改您的 IIS 以处理 64 位处理:工具 |选项 |项目和解决方案 |网站项目 |使用 64 位版本的 IIS Express

    【讨论】:

      猜你喜欢
      • 2010-10-18
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 1970-01-01
      • 2010-12-12
      相关资源
      最近更新 更多