tags:

views:

1433

answers:

4

Hello,

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.

+5  A: 

Turn on fusion logging?

This blog entry from Brad Wilson gives information on what to do if that fails...

Jon Skeet
I completely missed that fusion logger. It solved my problem within a few minutes because the logs are really useful. The FUSLOGVW.exe can just be copied to a machine (no .net SDK needed) and it's possible to set the logging settings through it. Magic. Thanks!
Michael Stum
+4  A: 

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.

Marc Gravell
+1  A: 

Grab the Microsoft Debugging Tools SDK, and use either windbg or cordbg to attach and run your application. This should give you at least a clue where the problem is, if not pinpoint the problem.

Miki Watts
+2  A: 

Hook and log AppDomain.AssemblyResolve

Mark Brackett