tags:

views:

58

answers:

4

I'm using Visual Studio 2008, with .net framework, C++/CLI. My program only runs in debug mode (even when run from explorer) - but in release mode it says program has stopped working. (But if I press F5 when it release mode it runs fine) All the settings are identical. What could it be? does anyone have any suggestions please?

+1  A: 

It's really hard to make a general claim as to what could be happening here. There are just too many things that could be causing a problem.

Your best bet is to deploy your application in release mode, attach a debugger and see what the failure is.

JaredPar
thanks - but what's the best way to attach a debugger?
Elliott
@Elliot, with Visual Studio go to Tools -> Attach To Process and select your application.
JaredPar
@Elliott C# express doesn't allow you to attach a debugger, in professional: Debug->Attach to process
McKay
Visual Studio Debug->Attach To Process -> select your process
mfeingold
thank you - that will definately be useful
Elliott
+1  A: 

I know that older versions of Visual Studio would set uninitialzed variables to zero in debug mode. In release mode, these variables would have potentially "random" values. I don't know if this happens with current versions of Visual Studio.

Is it possible that an uninitialzed variable is causing problems in your code?

Starkey
hey great - it works fine now - i would have never have noticed it otherwise. thanks
Elliott
@Elliott, if this was your problem, select his answer as correct.
McKay
A: 

This may be a wild guess but...

In debug mode everything is initialized to the default value if you haven't explicitly initialized it yourself. In Release mode, the same is not true. So, it could be that you're not hitting the same logic path within your C++ code as you do in Debug and this is causing the error.

wheaties
A: 

Couple of ideas:

  1. If your app is still dependent on the CRT, you may be having issues deploying/running it on other machines that don't have the correct version. Use dependency walker to look at your release mode exe, and also try profiling with dependency walker as well, the log can shed some light on various issues. www.dependencywalker.com

  2. As others have pointed out release mode removes many of the safety guards that debug mode puts in place. I would try turning on gflags from with "Debugging Tools for Windows" with your executable - and just run the program in debug mode. This will catch entire classes of problems that may not be caught with the normal debug mode safety guards.

  3. Finally if the above two solutions don't help, turn your 'Debug' project settings into a release build. Do this by changing the settings of the project that make it a 'Debug' build one setting at a time until you find the setting that makes your problem appear and work from there.

Zac