Detect if app was started from VS

Detect if app was started from VS

am 17.11.2007 21:57:47 von 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

Re: Detect if app was started from VS

am 18.11.2007 09:35:45 von 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.

"bz" schrieb im Newsbeitrag
news:fc1d3b1e-85d0-4693-98f9-533e8a15051a@e1g2000hsh.googleg roups.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

Re: Detect if app was started from VS

am 18.11.2007 13:05:57 von BZ

On 18 Noi, 10:35, "Christoph Hausner"
wrote:
> 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 w=
as
> started from Visual Studio:
>
> string[] args =3D 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



>
> I'm sure there are more elegant solutions but this is one of the easiest.
>
> "bz" schrieb im Newsbeitragnews:fc1d3b1e-85d0-4693-98f=
9-533e8a15051a@e1g2000hsh.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=BAare text =EEn citat -