HighTechTalks DotNet Forums  

Detect if app was started from VS

Dotnet General Discussions microsoft.public.dotnet.general


Discuss Detect if app was started from VS in the Dotnet General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
bz
 
Posts: n/a

Default Detect if app was started from VS - 11-17-2007 , 03:57 PM






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

Reply With Quote
  #2  
Old   
Christoph Hausner
 
Posts: n/a

Default Re: Detect if app was started from VS - 11-18-2007 , 03:35 AM






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.

"bz" <bzamfir (AT) gmail (DOT) com> schrieb im Newsbeitrag
news:fc1d3b1e-85d0-4693-98f9-533e8a15051a (AT) e1g2000hsh (DOT) googlegroups.com...
Quote:
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


Reply With Quote
  #3  
Old   
bz
 
Posts: n/a

Default Re: Detect if app was started from VS - 11-18-2007 , 07:05 AM



On 18 Noi, 10:35, "Christoph Hausner" <christoph_haus... (AT) hotmail (DOT) de>
wrote:
Quote:
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



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

"bz" <bzam... (AT) gmail (DOT) com> schrieb im Newsbeitragnews:fc1d3b1e-85d0-4693-98f9-533e8a15051a (AT) e1g2000hsh (DOT) googlegroups.com...



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- Ascunde citatul -

- Afișare text în citat -


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.