c# - Try-Catch in Program.cs only works when started from visual studio -


i tried write little crash reporter uncatched expetions. works when starting app in vs. try start .exe shows me standard "there uncaught expetion"-thingy windows. , no it's not crashreporter crashes.

this code in program.cs

        try         {             application.run(new testserver());         }         catch (exception e)         {             application.run(new crashreporter(e.stacktrace.tostring()));         }     } 

this because use debugger. winforms detects , disables event handler application.threadexception. that's important, lets debug exceptions. catch clause work without debugger, you'll have add statement main() method, before run() call:

   application.setunhandledexceptionmode(unhandledexceptionmode.throwexception); 

it make more sense write event handler appdomain.current.unhandledexception instead, you'll notified unhandled exceptions in worker threads.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -