By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

DesignMode

P: n/a
Is there any way for a program to autodetect when it is being run in Visual
Studio vs being run from a compiled program that has been installed? I have
tried DesignMode, but it always returns FALSE.

Thanks, Bobbo
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Robert,

There are statements for in DebugMode

http://groups.google.com/group/micro...3bf6a92?hl=en&

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
"Robert Liles" <rl****@midsouth.rr.com> schrieb:
Is there any way for a program to autodetect when it is being run in
Visual Studio vs being run from a compiled program that has been
installed? I have tried DesignMode, but it always returns FALSE.


Maybe the following solutions fit your requirements:

\\\
#If DEBUG Then
Console.WriteLine("Debug mode.")
#Else
Console.WriteLine("Release mode.")
#End If
///

Make sure that the option "Configuration settings" -> "Build" "Define DEBUG
constant" in the project properties is checked.

- and/or -

You can check if a debugger is attached:
'System.Diagnostics.Debugger.IsAttached'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
Thank you. I will give those a try.

Bobbo
__________________________________________________ _____________

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uD**************@TK2MSFTNGP15.phx.gbl...
"Robert Liles" <rl****@midsouth.rr.com> schrieb:
Is there any way for a program to autodetect when it is being run in
Visual Studio vs being run from a compiled program that has been
installed? I have tried DesignMode, but it always returns FALSE.


Maybe the following solutions fit your requirements:

\\\
#If DEBUG Then
Console.WriteLine("Debug mode.")
#Else
Console.WriteLine("Release mode.")
#End If
///

Make sure that the option "Configuration settings" -> "Build" "Define
DEBUG
constant" in the project properties is checked.

- and/or -

You can check if a debugger is attached:
'System.Diagnostics.Debugger.IsAttached'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
Thank you. I will give that a try.

Bobbo

__________________________________________________ ______________________

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OL*************@TK2MSFTNGP15.phx.gbl...
Robert,

There are statements for in DebugMode

http://groups.google.com/group/micro...3bf6a92?hl=en&

I hope this helps,

Cor

Nov 21 '05 #5

P: n/a
On 2005-09-18, Robert Liles <rl****@midsouth.rr.com> wrote:
Is there any way for a program to autodetect when it is being run in Visual
Studio vs being run from a compiled program that has been installed? I have
tried DesignMode, but it always returns FALSE.


To follow up on what others have said, you're going to have be more
specific in your requirements. Do you need to detect...

Am I running in VS in design mode, which is what the DesignMode property
returns.

Am I running under a debugger, which
System.Diagnostics.Debugger.IsAttached returns

Am I compiled for Debug, for which "#if DEBUG" is useful

Was I started from Visual Studio, which I'm not really sure how to
detect.

Was this program installed with the installer, which is probably most
easily detected by setting a registry variable during installation.

I'm not sure exactly what your requirements are, but all these are
different. The other option that I usually use is to simply use
something out of App.Config to determine mode. This would allow you
to easily emulate installed environments even when debugging...

Nov 21 '05 #6

P: n/a
Thank you. That gives me something to work with.

Bobbo

__________________________________________________ _____________________

"david" <da***@woofix.local.dom> wrote in message
news:sl******************@localhost.localdomain...
On 2005-09-18, Robert Liles <rl****@midsouth.rr.com> wrote:
Is there any way for a program to autodetect when it is being run in
Visual
Studio vs being run from a compiled program that has been installed? I
have
tried DesignMode, but it always returns FALSE.


To follow up on what others have said, you're going to have be more
specific in your requirements. Do you need to detect...

Am I running in VS in design mode, which is what the DesignMode property
returns.

Am I running under a debugger, which
System.Diagnostics.Debugger.IsAttached returns

Am I compiled for Debug, for which "#if DEBUG" is useful

Was I started from Visual Studio, which I'm not really sure how to
detect.

Was this program installed with the installer, which is probably most
easily detected by setting a registry variable during installation.

I'm not sure exactly what your requirements are, but all these are
different. The other option that I usually use is to simply use
something out of App.Config to determine mode. This would allow you
to easily emulate installed environments even when debugging...

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.