views:

243

answers:

4

I have a recurrent issue with .NET applications that don't start (on others systems than mine). The fact is that I cannot, unfortunately, always create a smoothly running package. Therefore I often have to send a ZIP file of my Debug or Release folder.

My real problem is that these applications doesn't tell WHY they're not starting. I just get no exception at all if I start them from the command line, neither in the EventLog, or even if I try to print on the output the result of a Try Catch block on all my application... am I missing something?

Most of the time, it's missing libraries, or security related issues. But it would be nice to find what exactly is going on painlessly :D

+3  A: 

Have you tried looking at the fusion logs? Suzanne Cook has an article on this here.

Another thing to do (to minimise silent errors): minimise your Main method; the reason for this is that JIT works per-method, and if it can't JIT Main it can't use your exception handling:

/* for winform, you still new [STAThread] here */
static void Main() {
  try {
     MainCore();
  } catch (Exception ex) {
     // shout about it
  }
}

[MethodImpl(MethodImplOptions.NoInlining)] // usually overkill
static void MainCore() {
  // real code
}
Marc Gravell
+3  A: 

Take a look at the Assembly Binding Log Viewer.

Michael Damatov
A: 

I know it's not addressing the problem directly - but have you tried publishing your application (assuming you're using Visual Studio of course)? This should wrap up everything you need into the installer.

ChrisF
A: 

I've had a problem whereby WPF applications wouldn't start - it turns out that the problem was related to fonts on the user's PC - disabling the WindowsPresentationFontCache service fixed the problem.

I also found a post elsewhere with the following info...

...for some unknown reason, the customer had wrong entries in the registry keys that are used to build that “default font family” cache cited in the stack trace. The customer was asked to export the entries under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts, and send the file to me. There were several font filenames strangely starting with dashes (---). These were fixed, and a registry file was sent back to the customer to import. After that, the application successfully started!

There may also be the need of deleting your font cache, as per instructions in this link http://support.microsoft.com/kb/937135

TabbyCool