Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Assembly Load - ConfigurationErrorsException

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?

like image 910
ilivewithian Avatar asked Nov 04 '22 22:11

ilivewithian


1 Answers

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.

like image 137
user1234883 Avatar answered Nov 14 '22 07:11

user1234883