简体   繁体   English

如何手动使C#代码崩溃

[英]How to manually crash c# code

I am facing lot of issue to exe crash on production server however I want to dump file when exe crash with detail log. 我在生产服务器上遇到exe崩溃的很多问题,但是当exe崩溃并显示详细日志时,我想转储文件。

I have found procdump tool. 我发现了procdump工具。 Can you suggest code c# which manually crash exe, so can check what kind of information get in dump log. 您能否建议手动使exe崩溃的c#代码,以便可以检查转储日志中包含哪些信息。

A crash is caused by an exception which is not caught. 崩溃是由未捕获的异常引起的。 Just throw one in your code 只需在您的代码中扔一个

throw new Exception();

and do not add a try-catch block anywhere. 并且不要在任何地方添加try-catch块。

The best, which can't be caught, is creating a stack overflow exception. 最好的,无法捕获的,是创建堆栈溢出异常。 This one will fall thru the try/catches... 这将通过尝试/抓住...

void MyMethod()
{
    MyMethod();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM