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?
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.
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?
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.
Couple of ideas:
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
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.
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.