Jigar Joshi
Jigar Joshi

Reputation: 143

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.

I have found procdump tool. Can you suggest code c# which manually crash exe, so can check what kind of information get in dump log.

Upvotes: 1

Views: 2407

Answers (2)

Jeroen van Langen
Jeroen van Langen

Reputation: 22083

The best, which can't be caught, is creating a stack overflow exception. This one will fall thru the try/catches...

void MyMethod()
{
    MyMethod();
}

Upvotes: 2

Thomas Weller
Thomas Weller

Reputation: 59641

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.

Upvotes: 5

Related Questions