views:

148

answers:

3

When I debug my C# program F5, my program will run as intended; however, upon building it CTRL+F5, my program immediately shuts down: "(Program) has stopped working". What are some possible explanations for this?

+3  A: 

Ctrl+F5 is usually not the shortcut for building, but for starting the program without the debugger attached.

I would guess that your program is then started with a different working folder and crashes because you somewhere try to access a file relative to the working folder that is not found when you start with Ctrl+F5.

0xA3
I was going to say this.
ChrisF
+6  A: 

Don't try to guess at this and write the code to tell you. Add an event handler for AppDomain.Current.UnhandledException and display the value of e.ExceptionObject.ToString().

Hans Passant
A: 

Are you referring to running the executable file (that results from building your application) outside of Visual Studio? Are you building in Debug or Release mode?

Bernard