I have a .net 3.5 WinForms application that runs fine on my machine, but on another machine it immediately crashes with a system.io.fileloadexception. Unfortunately, there are absolutely no details on which file failed to load, so I do not know where the problem actually is.
I believe I know which one it could be (SQL Server Compact edition), but before I aimlessly hunt, I wonder if there is a proper way to find out what caused the fileloadexception, other than using FileMon from SysInternals.
The only error message is:
EventType clr20r3, P1 myapplication.exe, P2 2.1.0.0, P3 490eca78, P4 myapplication, P5 2.1.0.0, P6 490eca78, P7 2e, P8 21, P9 system.io.fileloadexception, P10 NIL.
Turn on fusion logging?
This blog entry from Brad Wilson gives information on what to do if that fails...
You could try making your Main()
method more robust to catch (and display) the exception... like so.
Frequently, the problem is that too much code gets into the outermost Main()
method. JIT has to be able to fully understand Main()
, otherwise none of your code can run. By making Main()
simpler, you stand a chance. In the linked example, if MainCore()
fails: fine, we can still catch the exception in Main()
.
This works because JIT is done on a method-by-method basis... i.e. MainCore()
is not JITted until it is invoked, by which time we already have our try/catch in place.
Hook and log AppDomain.AssemblyResolve
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With