如何调试程序集加载 - ConfigurationErrorsException

5

我有一个应用程序,在本地运行良好,但是在部署时出现以下错误:

Exception information: 
    Exception type: ConfigurationErrorsException 
    Exception message: Could not load file or assembly 'FluentMigrator.Runner' or one of its dependencies. An attempt was made to load a program with an incorrect format.
    at System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)
    at System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
    at System.Web.Configuration.AssemblyInfo.get_AssemblyInternal()
    at System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)
    at System.Web.Compilation.BuildManager.CallPreStartInitMethods()
    at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

我尝试使用Assembly Binding Log Viewer查看程序集绑定日志,但即使打开了该日志,我也无法获得比上面的堆栈跟踪更多的信息,日志似乎保持为空白。它抱怨的程序集存在,并且从表面上看似乎所有依赖的程序集都存在。我还能做什么来调试服务器上的问题呢?

1个回答

2
这个错误与架构不匹配有关,即你的二进制文件可能希望在x86进程中运行,但IIS将其运行在x64进程中(或反之亦然)。这可以在应用程序池设置中进行配置。
为了调试此问题,您可以尝试以下操作: 1)启用融合日志记录(如何在.NET中启用程序集绑定失败日志记录(Fusion))。
2)使用Windows调试器(WinDbg)和加载器快照。请参见此处如何设置。 (http://www.microsoft.com/msj/0999/hood/hood0999.aspx)
在WinDbg中,使用sxeclr命令捕获托管异常。当遇到ConfigurationErrorsException异常时,应运行.loadby sos clr命令,然后运行!pe命令,这将显示有关异常的更多详细信息。同时,加载程序快照应该显示哪个dll存在加载问题。您需要在WinDBG下运行您的IIS工作进程(w3wp.exe)。您应该使用gflags进行配置。通常2)可以帮助处理C++/CLI程序集的问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接