Lukas Šalkauskas
Lukas Šalkauskas

Reputation: 14361

How to catch this type of exceptions?

I'm starting getting tired of this exception. Can't handle it, even so I'm using this:

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

Still no success, Can anyone explain me, how I should handle it in a nice way. Or how to detect that it have fired this message and close the application, because I'm starting it automatically everytime it closes.

Btw, It's Console application.

alt text

Upvotes: 4

Views: 234

Answers (4)

Lukas Šalkauskas
Lukas Šalkauskas

Reputation: 14361

IMHO best way solving this is to use remote debugging.

Upvotes: 1

Tim Lloyd
Tim Lloyd

Reputation: 38434

Are you using any P/Invoke calls at all? I have had issues in the past with C interop before, where the C dll was causing an access violation error internally, which in turn crashed the C# application catastrophically - much like your screenshot above. Unfortunately it turned into a case of hunting down the entry point (P/Invoke) into the C dll by trial and error, and then fixing the C code.

If you are using P/Invoke, are all the expected dependencies on the machines and the correct versions?

Upvotes: 0

Jehof
Jehof

Reputation: 35544

Here and here ´s are some good posts, why you get the Dialog even when you register the UnhandledExceptionEvent.

If you register to the event, it doesn´t prevent the application from beeing closed/exited. As far as i know it is by design. In the Event you have the option to log the exception and verify what went wrong in your application.

Upvotes: 0

ChrisBD
ChrisBD

Reputation: 9209

Have you tried placing a try{...} catch(Exception e){...} block in your main, then posting all exception data to the Windows Event Viewer? Or similarly checking the Windows Event information that is currently there.

Upvotes: 1

Related Questions