如何调试程序集加载 - ConfigurationErrorsException
我有一个在本地运行良好的应用程序,但是在部署时我看到了错误:
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)
我尝试通过程序集绑定日志查看器查看程序集绑定日志,但即使打开了它,我也没有得到更多信息与上面的堆栈跟踪相比,日志似乎保持为空。它所抱怨的程序集存在,并且从表面上看,它的所有依赖程序集都存在。我还能做什么来调试服务器上的错误?
I've got an application that runs fine locally, but when deployed I'm seeing the error:
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)
I've tried viewing the assembly bindings log through the Assembly Binding Log Viewer, but even with that turned on I'm getting no more information than the above stack trace, the log seems to stay empty. The assembly that it's complaining about is present and on the face of it has all of it's dependant assemblies present. What else can I do to debug what wrong on my server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误与体系结构不匹配有关,即您的二进制文件可能希望在 x86 进程中运行,但 IIS 在 x64 进程中运行它们(反之亦然)。这可以在应用程序池设置中进行配置。
要调试该问题,您可以尝试以下操作:
1)启用融合日志记录(
如何在 . NET
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 程序集。
This error is related to architecture mismatch, i.e. your binaries probably expect to run in x86 process, but IIS runs these in x64 process (or vice versa). This is configurable in App Pool settings.
To debug the issue, you could try the following:
1) Enable fusion logging (
How to enable assembly bind failure logging (Fusion) in .NET
2) Using windows debugger (WinDbg) with loader snaps.
Please see here how to set it up.
http://www.microsoft.com/msj/0999/hood/hood0999.aspx
Also when in WinDbg catch managed exception with sxeclr command
When you hit ConfigurationErrorsException, you should run .loadby sos clr command, then !pe - this should display more details on the exception. At the same time, loader snaps should show which dll is having loading problems.
You'd need to run your IIS worker process (w3wp.exe) under WinDBG. You should use gflags to configure that.
Usually 2) would help with C++/CLI assemblies.