Is there a way to determine if the attached debugger is a remote debugger?

Using System.Diagnostics.Debugger.Debugger.IsAttached

, I can tell that the debugger is connected. Is there a way to determine if the attached debugger is a remote debugger ( Visual Studio Remote Debugger Monitor

)?

+3


source to share


1 answer


You can use your own CheckRemoteDebuggerPresent

fromkernel32.dll

From MSDN :

"remote" in CheckRemoteDebuggerPresent does not mean that the debugger is necessarily on another computer; instead, indicates that the debugger is in a separate and parallel process.



You can use it like this:

[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CheckRemoteDebuggerPresent(IntPtr hProcess, ref bool isDebuggerPresent);

public static void Main()
{
    bool isDebuggerPresent = false;
    CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref isDebuggerPresent);

    Console.WriteLine(string.Format("Debugger Attached: {0}", isDebuggerPresent));
    Console.ReadLine();
}

      

+3


source







All Articles