简体   繁体   中英

Cannot resolve symbol 'Dte' with envdte reference

i try to detect debugger and i get error "Cannot resolve symbol 'Dte'" even with envdte reference. Google give me nothing. Thank you.

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# is a case sensitive language.

Its DTE (in upper case) not Dte . Documentation at https://msdn.microsoft.com/en-us/library/envdte.dte.aspx

I need to detect is debugger (like Ollydbg) attached

To check if the process has a debugger attached to yo can use:

How to check if debugger is attached

  • CheckRemoteDebuggerPresent works for any running process and detects native debuggers too.

  • Debugger.IsAttached works only for the current process and detects only managed debuggers. As an example, OllyDbg won't be detected by this .

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();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM