Olaf Hess
Olaf Hess

Reputation: 1483

.NET equivalent to Delphi's "DebugHook" variable to test for presence of debugger

When a program is running under the control of the debugger in the Delphi IDE, it is possible to detect this because the variable "DebugHook" is set to a value <> 0.

Is there an equally easy way to check for the debugger when debugging a .NET program in Visual Studio?

Upvotes: 1

Views: 221

Answers (1)

Olaf Hess
Olaf Hess

Reputation: 1483

To achieve the same in .NET reference "System.Diagnostics" and add this code

if (System.Diagnostics.Debugger.IsAttached) then
   // Program is running under the control of the debugger

Upvotes: 1

Related Questions