0

I have an application developed on VB.NET2010 and I need to enable some objects only when is in debug mode.

The application can know when is being debugged?

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103
E_Blue
  • 1,021
  • 1
  • 20
  • 45

2 Answers2

2

you can try to add these preprocessor lines in your script!

#If DEBUG Then
Console.WriteLine("Debug mode.")
#Else
Console.WriteLine("Release mode.")
#End If

You will get the result as per conditions.

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103
  • This will not determine if the application is being debugged or not, rather it says if it was built with the Debug configuration or not. – Oskar Sjöberg Jan 02 '14 at 19:28
2

Example:

if (Debugger.IsAttached)
{
    ....
}

(Debugger belongs to the System.Diagnostics namespace)

Oskar Sjöberg
  • 2,728
  • 27
  • 31