Hi all,
how could I detect in code whether I'm running the executable or whether I'm running my project from the .NET IDE? Does someone have a coding example for me?
Thanx in advance,
Marco
Printable View
Hi all,
how could I detect in code whether I'm running the executable or whether I'm running my project from the .NET IDE? Does someone have a coding example for me?
Thanx in advance,
Marco
You use conditional compilation to compile different code depending on whether you are in Debug or Release:Note that this If statement is NOT executed at run time. Depending on whether you are compiling a Debug or Release build, only one of the MessageBox lines will be compiled into your executable.VB Code:
#If DEBUG Then MessageBox.Show("Debug") #Else MessageBox.Show("Release") #End If
So 'DEBUG' is a keyword, and not a private declared variable, according to your code? In that case, solved and many thanx...Quote:
Originally Posted by jmcilhinney
No, DEBUG is not a keyword. It is a conditional compilation constant. Open the Property Pages for your project and take a look at the Configuration Properties -> Build section. If you change the configuration between Release and Debug you will see that by default DEBUG and TRACE are defined for the Debug configuration but only TRACE is defined for the Release configuration. You can also define your own constants. I have an application that I have customised for one particular customer. I defined a conditional compilation constant to control which code gets compiled. When the constant is defined the custom code is compiled into the build. If the constant is not defined then the normal code gets compiled. You can create addtional configurations for your project other than just Release and Debug that include different settings, including these constants. You then just change the configuration on the toolbar and voila.