|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to detect if program execution is in debug mode?If I'm running the executable, I need to do something, but if I am running
the program fom within Visual studio I need to use another bit of code. Thanks for any help. Bob "Bob" <bduf***@sgiims.com> schrieb: Maybe the following solutions fit your requirements:> If I'm running the executable, I need to do something, but if I am running > the program fom within Visual studio I need to use another bit of code. \\\ #If DEBUG Then Console.WriteLine("Debug mode.") #Else Console.WriteLine("Release mode.") #End If /// Make sure that the option "Configuration settings" -> "Build" "Define DEBUG constant" in the project properties is checked. - and/or - You can check if a debugger is attached: 'System.Diagnostics.Debugger.IsAttached'. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks
Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:OOQrGuYvGHA.4456@TK2MSFTNGP06.phx.gbl... > "Bob" <bduf***@sgiims.com> schrieb: >> If I'm running the executable, I need to do something, but if I am >> running the program fom within Visual studio I need to use another bit of >> code. > > Maybe the following solutions fit your requirements: > > \\\ > #If DEBUG Then > Console.WriteLine("Debug mode.") > #Else > Console.WriteLine("Release mode.") > #End If > /// > > Make sure that the option "Configuration settings" -> "Build" "Define > DEBUG > constant" in the project properties is checked. > > - and/or - > > You can check if a debugger is attached: > 'System.Diagnostics.Debugger.IsAttached'. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> Bob wrote:
> If I'm running the executable, I need to do something, but if I am running If System.Diagnostics.Debugger.IsAttached Then> the program fom within Visual studio I need to use another bit of code. ' Debugging Else ' Running from Executable End If HTH, Phill W.
Can I make my program more efficient ?
My for each loops do not compile - VB 2003 Can anyone help in shortening this loop??? tcpListener.AcceptSocket strange behavior execution from command line Form2.vb[design] innaccessible ! Binding an Image to a picturebox Problem with CustomTyped casting and type checking VB .Net pound problem - HELP! Encryption: VB 2005 And SQL Server 2005 |
|||||||||||||||||||||||