472,335 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,335 software developers and data experts.

How can I determine if the app is running in Debug mode or Release mode?

I found the following code snippet in the help but it doesn't seem to
compile.

Dim debugger As EnvDTE.Debugger
Dim IsDebugging As Boolean

debugger = DTE.Debugger

If (debugger Is Nothing) Then
MsgBox("Debugger doesn't exist! Fatal error.")
IsDebugging = False
Else
IsDebugging = (debugger.CurrentMode <>
dbgDebugMode.dbgDesignMode)
End If

I'm getting an error on "DTE.Debugger" saying "Reference to a non-shared
member requires an object reference."

So what did Microsoft leave out? Is there a different way to do this that's
better?
Thanks in advance for the help.

Tom P.
Nov 21 '05 #1
4 21962
"Henry Padilla" <pa******@hotmail.com> schrieb:
[How can I determine if the app is running in Debug mode or Release mode?]


\\\
#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 #2

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
"Henry Padilla" <pa******@hotmail.com> schrieb:
[How can I determine if the app is running in Debug mode or Release
mode?]
\\\
#If DEBUG Then
Console.WriteLine("Debug mode.")
#Else
Console.WriteLine("Release mode.")
#End If
///


That's C# not VB. In VB this gets confused with the Debug() object.

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'.

This I might try. Thanks!

Tom P.

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

Nov 21 '05 #3
I found the problem, I needed to declare the DTE object. Like so:

Dim DTE as EnvDTE.DTE
DTE =
System.Runtime.InteropServices.Marshal.GetActiveOb ject("VisualStudio.DTE")
"Henry Padilla" <pa******@hotmail.com> wrote in message
news:bA****************@newssvr19.news.prodigy.com ...

Dim debugger As EnvDTE.Debugger
Dim IsDebugging As Boolean

debugger = DTE.Debugger

If (debugger Is Nothing) Then
MsgBox("Debugger doesn't exist! Fatal error.")
IsDebugging = False
Else
IsDebugging = (debugger.CurrentMode <>
dbgDebugMode.dbgDesignMode)
End If

Tom P.
Nov 21 '05 #4
"Henry Padilla" <pa******@hotmail.com> schrieb:
[How can I determine if the app is running in Debug mode or Release
mode?]


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


That's C# not VB. In VB this gets confused with the Debug() object.


The code above should work in VB.NET.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Le | last post by:
Hi I would like to know if there was a way to know if you are running in debug or release mode at runtime for VB This way I could execute certain...
4
by: xTroLL | last post by:
Hi, I want to get the running mode (DEBUG or RELEASE) of my application ? Somebody can help me ? xTroLL --------------= Posted using...
7
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed...
3
by: Rob Nicholson | last post by:
How do you determine if a program is running in the Visual Studio IDE/debugger as opposed to standalone? We often include support files in the same...
4
by: Tom | last post by:
How can one determine if a .NET program is running in the developer IDE or running stand-alone? I am sure I saw something somewhere but I don't...
3
by: Haldun ALIML | last post by:
Suppose that you have below property in some class, #if DEBUG public string DebugInfo { get { return "INDEX : " + _name + "\n" + "Index Owner...
9
by: Michael.Suarez | last post by:
Suppose I have a program that prompts you with a dialogbox to enter a password. If you get the password correct, it allows you into the program,...
2
by: Dave Johansen | last post by:
I just converted a solution from Visual Studio 2003 to Visual Studio 2005 and the Debug mode seems to be running just fine, but the Release mode...
0
by: =?Utf-8?B?SmVmLnB0Yw==?= | last post by:
Hi, I am currently facing exactly the same issue with Visual Studio 2005. Did you find a way to solve this problem ? "AntonioSACE" wrote:
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.