Detect if app was started from VS

B

bz

Hi,

I need to detect at runtime if the application was started from VS
2005. Is it possible?
Also, how can I know at runtime of app is built for Debug or Release?

Thanks
 
C

Christoph Hausner

You can tell Visual Studio to run your application with a special command
line argument. Click Project -> Properties -> Debug and enter "/debug" as an
argument. Use the following if-statement in your program to detect if it was
started from Visual Studio:

string[] args = Environment.GetCommandLineArgs(); // remove this line if
your program is a console application
if (args.Length > 0 && args[0] == "/debug")
// started from VS
else
// not started from VS

I'm sure there are more elegant solutions but this is one of the easiest.
 
B

bz

You can tell Visual Studio to run your application with a special command
line argument. Click Project -> Properties -> Debug and enter "/debug" as an
argument. Use the following if-statement in your program to detect if it was
started from Visual Studio:

string[] args = Environment.GetCommandLineArgs(); // remove this line if
your program is a console application
if (args.Length > 0 && args[0] == "/debug")
// started from VS
else
// not started from VS

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top