Close application without .net framework's error prompt window

前端 未结 2 1895
情书的邮戳
情书的邮戳 2021-01-27 14:12

Codes handles unhandled exceptions as below in my project.

   static void FnUnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs _UnhandledE         


        
2条回答
  •  心在旅途
    2021-01-27 14:44

    You may want to look into the Application.SetUnhandledExceptionMode method. Calling this with the UnhandledExceptionMode.ThrowException parameter will prevent Winform to route exceptions down to the Application.ThreadException event and thus this dialog won't ever show up.

    You can also alter the app.config file to get the same result:

    
      
    
    

    Personnaly I prefer the hard-coded route.

    Just so we're clear: this will only get rid of the dialog, not solve the actual assembly loading or app freezing problem. :)

提交回复
热议问题