469,626 Members | 1,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Determine if program is running in Visual Studio IDE

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
3 2584
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
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
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.

Similar topics

18 posts views Thread by Christopher W. Douglas | last post: by
4 posts views Thread by John Bailo | last post: by
14 posts views Thread by jmDesktop | last post: by
4 posts views Thread by =?Utf-8?B?Q1IgU3VwcG9ydA==?= | last post: by
1 post views Thread by =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.