How to determine if in developer IDE or stand-alone?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

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
remember where or what.

Thanks!

Tom
 
Tom said:
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
remember where or what.

Try the shared property:

System.Diagnostics.Debugger.IsAttached

Cheers

Arne Janning
 
Tom said:
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
remember where or what.

In VB6 I've been using, and it should work similarly from VB.NET:

Public Function IsRunFromIDE() As Boolean
Debug.Assert MakeTrue(IsRunFromIDE) Or True
End Function

Private Function MakeTrue(ByRef bItem As Boolean)
bItem = True
End Function
 
None of the methods suggested will determine if you are started from the
IDE. You can come to the same conclusion by testing this code (perhaps in
page_load).

Debug.WriteLine("DebugWriteLine")
#If DEBUG Then
Debug.WriteLine("If Debug> DebugWriteLine")
#Else
Debug.WriteLine("Else Release> DebugWriteLine")
#End If
If System.Diagnostics.Debugger.IsAttached() Then
Debug.WriteLine("Debugger Is Attached")
Else
Debug.WriteLine("Debugger Is Not Attached")
End If

If the project is in Debug mode, and started with F5, you get everything you
expect.

If the project is in Debug mode, and started with Ctrl-F5, you can still see
the debug output, but you have to use an external debug catcher (e.g.
dbgview from www.sysinternals.com). You get the output you expect.

If you set the project to Release mode, you get nothing, but only because I
used Debug.Writeline; your program would execute the #Else code.

So we still have the question how to determine if the IDE started the
program? Still looking.
 
Back
Top