c# console application - prevent default exception dialog -


I have a simple application with a single application that is launched from time to time on a server. Sometimes inexplicable exceptions occur in the application and default stop / retry / ignore dialogue pops up. I need to stop the ADIL from appearing in some way and just have to output the exception to the stranger and close the application. So I tried - with the catch statement closed all the codes in the main method, but it does not help at all - the exception dialog is sometimes displayed.

The main () code looks like this:

  Try {RunApplication (); } Hold (exception exc) {Console.Error.WriteLine (exc.ToString ()); Console.Error.WriteLine (exc.StackTrace); If (exc.InnerException! = Null) {Console.Error.WriteLine (exc.InnerException.ToString ()); Console.Error.WriteLine (exc.InnerException.StackTrace); } environment. EXT (666); }  

This try-catching section should not catch all unrestricted exceptions and popup AFAIK at any time. Am I forgetting something? Or is there any setting (registry etc) on the server that controls certain special behavior related to the exception dialog / application error code?

is an unrestricted exception event that you can subscribe to in the application domain.

  public static zero main () {AppDomain.CurrentDomain.UnhandledException + = New UnhandledExceptionEventHandler (OnUnhandledException); // some code here ....} /// & lt; Summary & gt; /// When you have an uncontrollable exception /// & lt; / Summary & gt; Public Static Zero On-Oned Expression (Object Sender, UnhandledExceptionEventArgs e) {// exception exception exception exception = exception (exception) e.ExceptionObject; // exit cleanly and do your logging}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -