views:

284

answers:

2

Hi,

I've written a c# windows app, that performs some DB intensive operations. (MySQL connector v6).

When running the project in Debug mode, everything works fine. However, when I run the prject in release mode, it sometimes quits operation midway - with no error message, nothing in the event logs etc.

What would be the best way to debug release mode - when everything works in debug mode?

Thanks for any help,

Bob

A: 

Bobby is correct in asking about Application Event Log. If it is bombing on a .NET error, it will likely be logged.

If that doesn't give you anything, wrap the entire app in a try/catch block. On your exception handling, log the error (application log, file, etc...). Make sure when you log it to capture the call stack.

Bomlin
Ack! Don't wrap everything in try/catch, use AppDomain.UnhandledException (http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx)
Paul Betts
The easiest way to capture the call stack is to use the ToString method to extract text from the exception, instead of the Message property. The other trick is to make sure never to rethrow an exception with "throw ex". Use "throw", which rethrows without losing the call stack, or throw a new exception that includes the original as the inner exception.
Steven Sudit
Sadly there's nothing in the Event logs (Including the application event log)I'll investigate and implement AppDomain.UnhandledException, and feedback my results.Thank you!
Bob
+1  A: 

You can create a log file and have the application write lines to it with information of your choice, similarly to how the console may be used for debug purposes in a windows form application. You can write values of certain variables to this file, or even just write distinct phrases in select places of the code that will help you detect where the program is in execution when it fails.

Exp HP