How to make C# application crash

后端 未结 12 2179
渐次进展
渐次进展 2020-12-31 13:00

I want to test if my application crash dump can be debugged. But firstly, I need to generate a crash dump of my application. I\'m using C# to code my app, and have tried wit

12条回答
  •  半阙折子戏
    2020-12-31 13:45

    A surefire way to do it is as follows:

    ThreadPool.QueueUserWorkItem(new WaitCallback(ignored => 
    {
       throw new Exception();
    }));
    

    All the others can be handled by the top level ApplicationDomain.OnUnhandledException and the like.

    This one will kill it dead (assuming .NET 2.0+, and not using 'legacyUnhandledExceptionPolicy': http://msdn.microsoft.com/en-us/library/ms228965.aspx).

提交回复
热议问题