tags:

views:

43

answers:

2

I'm coding an application on C#, and it runs perfectly fine when I click the "Run" button in Visual Studio C# Express 2010. But, when I go to Debug -> Build Solution, after I run the .exe file, it says "XXX.EXE has stopped working..."

I have inserted break-points and commented out chunks of my code, rebuilt the project, and ran again to try to isolate the problem, but I can't figure out what is causing this. The fact that it runs fine in debug mode is strange.

A: 

hmm man this is strange have you made sure you didn't rename anything in the properties or change existing code or is this from scratch

Steven Colgrove
+1  A: 

Some things to try:

Check the system Event log for ASP.NET errors.

Try setting the build to Release mode and using Run--no debugging. See if it crashes then. Watch the Output and other windows for any errors during/after the crash. Depending on those results, check that your solution and project properties are correct in both Debug and Release configurations.

You can also build in debug mode, launch it externally, than attach the Visual Studio debugger to the process. But of course if it crashes on startup than that won't work.

You can add Debug.Assert lines to see if you can get one of those to throw.

Wrap your code in a big try/catch and make sure your catch handler somehow reports or logs the full exception for you.

Adding logging would be good idea. You can log to a file or the system event log. I suggest log4net or similar logging tool for that.

Mufasa