我使用的是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位应用程序池false:错误
构建AnyCPU,32位应用程序池false:错误
构建x64,32位应用程序池true:错误
构建x86,32位应用程序池true:确定
构建AnyCPU,32位应用程序池为真:好的
IIS Express:好的
如何找到64位配置中使用的32位问题dll?
答案 0 :(得分:6)
我发现了问题。我使用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
属性