无法使用 envdte 引用解析符号 'Dte'

Cannot resolve symbol 'Dte' with envdte reference

我尝试检测调试器,但我收到错误 "Cannot resolve symbol 'Dte'",即使有 envdte 参考。 Google什么都不给我。谢谢。

using EnvDTE;
namespace test
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            foreach (EnvDTE.Process p in Dte.Debugger.DebuggedProcesses) {
                if (p.ProcessID == spawnedProcess.Id) {

                }
            }
        }
    }
}

C# 是区分大小写的语言。

它是 DTE(大写)而不是 Dtehttps://msdn.microsoft.com/en-us/library/envdte.dte.aspx

处的文档

I need to detect is debugger (like Ollydbg) attached

要检查进程是否附加了调试器,您可以使用:

如何检查是否附加了调试器

  • CheckRemoteDebuggerPresent 适用于任何 运行 进程并检测本机调试器。

  • Debugger.IsAttached 仅适用于当前进程并且仅检测托管调试器。例如,OllyDbg 将不会被此.

  • 检测到

Code:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

public class DetectDebugger
{
    [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("Debugger Attached: " + isDebuggerPresent);
        Console.ReadLine();
    }
}