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

Determine if program is running in Visual Studio IDE

P: n/a
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 folder as the executable and would so something like:

Dim SupportFile As String
SupportFile = Application.StartupPath & "\SupportFile.txt"

But of course this fails when running in the IDE as the executable is in the
BIN folder so we need to do something like this:

Readonly Property SupportFilesPath() As String
Get
If IsIde() Then
SupportFilesPath = Application.StartupPath & "..\"
Else
SupportFilesPath = Application.StartupPath & "\"
End If
End Get
End Property

Need to implement that IsIde() function/property...

Thanks, Rob.
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
system.diagnostics.debugger.isattached

--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"Rob Nicholson" <rob.nicholson@NOSPAM_informed-direct.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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 folder as the executable and would so something like:

Dim SupportFile As String
SupportFile = Application.StartupPath & "\SupportFile.txt"

But of course this fails when running in the IDE as the executable is in the BIN folder so we need to do something like this:

Readonly Property SupportFilesPath() As String
Get
If IsIde() Then
SupportFilesPath = Application.StartupPath & "..\"
Else
SupportFilesPath = Application.StartupPath & "\"
End If
End Get
End Property

Need to implement that IsIde() function/property...

Thanks, Rob.

Nov 20 '05 #2

P: n/a
Maybe this will help:
http://www.dotnet247.com/247referenc...48/240629.aspx

Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com

"Rob Nicholson" wrote:
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 folder as the executable and would so something like:

Dim SupportFile As String
SupportFile = Application.StartupPath & "\SupportFile.txt"

But of course this fails when running in the IDE as the executable is in the
BIN folder so we need to do something like this:

Readonly Property SupportFilesPath() As String
Get
If IsIde() Then
SupportFilesPath = Application.StartupPath & "..\"
Else
SupportFilesPath = Application.StartupPath & "\"
End If
End Get
End Property

Need to implement that IsIde() function/property...

Thanks, Rob.

Nov 20 '05 #3

P: n/a
Rob Nicholson schrieb:
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 folder as the executable and would so something like:


You may want to experiment with:

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

You can check if a debugger is attached by calling
'System.Diagnostics.Debugger.IsAttached'. I think that's more what you
want to find out than checking the 'DEBUG' constant.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.