Results 1 to 5 of 5

Thread: How can I tell if the code is being debugged in the .NET IDE???

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    How can I tell if the code is being debugged in the .NET IDE???

    I have some code, and I want to do something like:
    VB Code:
    1. Dim RandomNumber As New Random
    2. If IsRunningInIDE Or Else RandomNumber.Next(0,11) = 10 Then
    3.    'do something
    4. End If
    I want some code to execute on a 1 in 10 chance. But when testing on my PC while running in IDE I want it to happen all the time.

    yea yea...I know code is compiled and executed from the DLL, but the IDE debugs it.

    Is this possible?

    Woof

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: How can I tell if the code is being debugged in the .NET IDE???

    Why not use a constant boolean. That way if the compiler is any good your debugger code won't even be executed when you set your boolean to false for a release build

  3. #3

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: How can I tell if the code is being debugged in the .NET IDE???

    Yea. Thought of that. But didn't want the "hassle" of changing a varible
    I am lazy.

    Woof

  4. #4
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: How can I tell if the code is being debugged in the .NET IDE???

    Your post reminded me that I had seen a Debugger name space before.

    Try

    Debugger.IsAttached


  5. #5

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: How can I tell if the code is being debugged in the .NET IDE???

    VB Code:
    1. If System.Diagnostics.Debugger.IsAttached Then
    2.        Response.Write("Woof")
    3. End If
    Cheers.

    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width