locked
Determining if you are DEBUGing while in Visual Studio?

    Question

  • Is there a way to know if you are debugging while you are running Visual Studio 2003 IDE?  I know you can build with DEBUG define but how can you tell if you are running IDE in order to turn certain features off?

     

    P.S. don't make fun that I am doing 2003 and not 2005 Wink  Our Delphi 6 app requires VS 2003...

     

    Thanks,

     

    Kenneth

    Wednesday, August 22, 2007 7:26 PM

Answers

  • I had a feeling that you are going in wrong direction. First, why checking are you in DEBUG or RELEASE mode is not good enough for your problem. Probably it is because you are always running your application in Debug mode.
    You can even when you run in Release mode to build your application with Full debug info which can be configured on project level, so when log exception to have full debug information where that bug ocurred. About exception handling, you will need to show some source, so we can see what to suggest. It's strange that you want to remove exception handling. Please give us detail explanation of your debuging problems.

    Wednesday, August 22, 2007 10:04 PM

All replies

  • Do you mean programmatically tell if one is debugging or visually by a user?

    Wednesday, August 22, 2007 7:32 PM
  • In the main form Load event do something like this:


    #if DEBUG
         menuForRealease.Visible = false;

    #endif


    You can put this coditional execution anywhere in your application.

    Wednesday, August 22, 2007 8:15 PM
  •  boban.s wrote:

    #if DEBUG
         menuForRealease.Visible = false;

    #endif



    I believe the OP is requesting how to tell if debugging is occruing and not just in a debug version of the code. That preprocessor command will always shows up regardless of whether the user is actively debugging or just running the application with debug code.
    Wednesday, August 22, 2007 9:03 PM
  • No I mean if there is a way to be able to tell if you are debugging while running Visual Studio IDE while in debug mode.  I know you have the DEBUG define but is the a way to tell if you are running Visual Studio to debug versus doing a debug build.

    Wednesday, August 22, 2007 9:07 PM
  • I'm not aware of such option to know programatically that you are debuging while running VS. Can you give litle more explanation Why you need such thing. Debug and Release mode of building application are nothing special, just preconfigured build configurations. You can create new configurations where you can configure project/solution build configurations as you like.

     

    Wednesday, August 22, 2007 9:48 PM
  • I will look at that again and see if I can create a define for such a purpose.  We just want a feature in our application during debugging while in Visual Studio IDE to turn off the exception handling we have.

     

    Thanks

    Wednesday, August 22, 2007 9:51 PM
  • I had a feeling that you are going in wrong direction. First, why checking are you in DEBUG or RELEASE mode is not good enough for your problem. Probably it is because you are always running your application in Debug mode.
    You can even when you run in Release mode to build your application with Full debug info which can be configured on project level, so when log exception to have full debug information where that bug ocurred. About exception handling, you will need to show some source, so we can see what to suggest. It's strange that you want to remove exception handling. Please give us detail explanation of your debuging problems.

    Wednesday, August 22, 2007 10:04 PM

  • Hi, Kenneth

    You can determine if your app is being debugged like this:

    Code Snippet

                if (System.Diagnostics.Debugger.IsAttached)
                {
                    //The app is being debugged
                }
                else
                {
                    //The app is running on its own.
                }


    (The IsDebuggerPresent API does not work for me...)

    Best Regards
    Chunsheng Tang
    Friday, August 24, 2007 8:13 AM
  • Yeah #if DEBUG is what we used.  There is no need to know if we are actually debugging while in Visual Studio 2005. Smile

     

    Thanks

    Saturday, August 25, 2007 10:08 AM