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

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

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
"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

P: n/a

"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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.