469,628 Members | 1,016 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

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

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
Nov 20 '05 #1
4 1450
Tom wrote:
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
Nov 20 '05 #2
Tom wrote:
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
Nov 20 '05 #3
* "Tom" <to*@nospam.com> scripsit:
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.


See:

<URL:http://www.google.de/groups?threadm=%23O1GIqAOEHA.4036%40TK2MSFTNGP12.p hx.gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
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.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de...
* "Tom" <to*@nospam.com> scripsit:
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.
See:

<URL:http://www.google.de/groups?threadm=...TK2MSFTNGP12.p
hx.gbl>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5

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
12 posts views Thread by clintonG | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.