Reputation: 1141
So my C# program is quitting/disapearing/closing/crashing suddenly even in debug mode. How can I make it break/pause/stop so as to find out where caused it?
Upvotes: 2
Views: 514
Reputation: 180874
Also, it may be worth checking your code for occurrences of Environment.FailFast, just in case someone tried to be (too) smart.
Upvotes: 1
Reputation: 2857
You can hit F10 to start debugging your project. This will put a breakpoint right at the beginning of your Main method, then you can go from there stepping through the code with F11 to see at which points it crashes.
Upvotes: 0
Reputation: 1957
as Eric suggested try going through step through it... also always place try/catch in your end caller apps in order to manage exceptions.
Upvotes: 1
Reputation: 56590
You may be able to learn more by using an unhandled exception handler. However, if you're in debug mode you should be able to see it by default. Check your Debug: Exceptions settings to make sure you haven't accidentally stopped reporting them in debug mode.
Upvotes: 3
Reputation: 170479
If you're in Visual Studio you can enable "Stop when an exception is thrown" - go Debug->Exceptions. This is often quite useful for detecting the exact source of the problem.
Upvotes: 3
Reputation: 95093
Set a breakpoint (by clicking the left of the line numbers--it's a red circle) that you know is before the point where it crashes and then step through it (using F8). The last statement that you're on is the one that it's crashing at.
Upvotes: 5