Matt126
Matt126

Reputation: 997

How to notice if the app is being debugged

I just program a game in Windows Phone 8 with an advertising, but the advertisement only works when the Phone isn't in Debug mode. Is there a possibility to notice if the app is being debugged or not?

I tried it so, but it don't works.

bool b1 = false;
#if DEBUG
            b1 = true;            
#endif
            if (!b1)
            {
                //no Debugging
            }

Upvotes: 1

Views: 85

Answers (1)

robwirving
robwirving

Reputation: 1798

The use of a preprocessor define will only tell you that you are running a debug version of the app. If you want to check that you are actively debugging, use this:

if (System.Diagnostics.Debugger.IsAttached)
{
  //Debug stuff
}

Upvotes: 8

Related Questions