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)

我已经尝试通过程序集绑定日志查看器查看程序集绑定日志,但即使打开了它,我也没有得到比上面的堆栈跟踪更多的信息,日志似乎保持为空。它抱怨的程序集是存在的,并且从表面上看,它的所有依赖程序集都存在。我还能做些什么来调试我的服务器上的错误?

4

1 回答 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 程序集。

于 2012-06-07T05:40:40.770 回答