64-bit - x64 上的 IIS 中的 BadImageFormatException

标签 64-bit iis-7.5 badimageformatexception

我正在使用 Windows 7 x64。启动 MVC 应用程序时出现 BadImageFormatException。如果它在启用了 32 位应用程序的应用程序池中运行,则不会引发异常。看起来加载 global.asax 是问题所在。我启用了融合日志记录 (HKLM\software\Microsft\Fusion!EnableLog) 注册表设置。这是日志:

    === Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: Where-ref bind. Location = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\spl.sim.mvc\5802065c\a2782d40\App_global.asax.olejmmua.dll
LOG: Appbase = file:///C:/Spl/SimSvn4.5/Source/Spl.Sim.Mvc/
LOG: Initial PrivatePath = C:\Spl\SimSvn4.5\Source\Spl.Sim.Mvc\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Spl\SimSvn4.5\Source\Spl.Sim.Mvc\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/spl.sim.mvc/5802065c/a2782d40/App_global.asax.olejmmua.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

使用不同的构建配置,结果如下:

构建 x64、32 位应用程序池 false:错误

构建 x86、32 位应用程序池错误:错误

构建 AnyCPU,32 位应用程序池 false:错误

构建 x64、32 位应用程序池 true:错误

构建 x86、32 位应用程序池 true:OK

构建 AnyCPU,32 位应用程序池 true:OK

IIS Express:好的

如何找到 64 位配置中使用的 32 位问题 dll?

最佳答案

我发现了问题。我使用 Instrumentation 进行分析。这将以下行添加到 web.config:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <codeBase version="11.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2011.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL" />
  </dependentAssembly>

从 web.config 部分删除这个dependentAssembly 后,程序按预期工作。我还删除了 assemblyPostProcessorType来自 compilation 的属性元素

关于64-bit - x64 上的 IIS 中的 BadImageFormatException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13156053/

相关文章:

c++ - 将 uint32_t 转换为 uint64_t 会产生不同的值?

c# - opencv_imgproc.dll 抛出 BadImageFormatException

c# - 无法在 Visual Studio 2010 中加载文件或程序集

datetime - 将 64 位时间戳转换为可读值

.net - 如何在64位.NET应用程序中显示SVG文件?

centos - Centos 6 64 位错误 : Jpeg Decoder not Available 的 PIL selftest.py 失败

.net - 为什么 IIS 在 PipelineRuntime.WaitForRequestsToDrain() 启动时卡住?

iis-7.5 - 两个匹配服务器上的 Web Deploy 2.0 中可用选项的差异

c# - 使用共享 IP 地址从 IIS 站点发出出站 Web 请求时失败

c# - 使 C# 程序能够在任何操作系统上编译