Determine if program is running in Visual Studio IDE

  • Thread starter Thread starter Rob Nicholson
  • Start date Start date
R

Rob Nicholson

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.
 
Rob said:
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.
 
Back
Top