private void AttachToRemoteProcess(string machineName, string processName)
        {
            IVsDebugger3 vsDebugger = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger3;

            VsDebugTargetInfo3[]       arrDebugTargetInfo   = new VsDebugTargetInfo3[1];
            VsDebugTargetProcessInfo[] arrTargetProcessInfo = new VsDebugTargetProcessInfo[1];

            arrDebugTargetInfo[0].bstrExe           = processName;
            arrDebugTargetInfo[0].bstrRemoteMachine = machineName;

            arrDebugTargetInfo[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning;
            arrDebugTargetInfo[0].guidLaunchDebugEngine = Guid.Empty;
            arrDebugTargetInfo[0].dwDebugEngineCount    = 1;

            Guid   guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid;
            IntPtr pGuids        = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine));

            Marshal.StructureToPtr(guidDbgEngine, pGuids, false);
            arrDebugTargetInfo[0].pDebugEngines = pGuids;
            int hr = vsDebugger.LaunchDebugTargets3(1, arrDebugTargetInfo, arrTargetProcessInfo);

            // cleanup
            if (pGuids != IntPtr.Zero)
            {
                Marshal.FreeCoTaskMem(pGuids);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DebugOnCF"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private DebugOnCF(AsyncPackage package, OleMenuCommandService commandService)
        {
            var debugger = (IVsDebugger)package.GetServiceAsync(typeof(IVsDebugger)).Result;

            _debugger = (IVsDebugger3)debugger;
            if (debugger != null)
            {
                debugger.AdviseDebugEventCallback(this);
            }
            _commandService = commandService;
            this.package    = package ?? throw new ArgumentNullException(nameof(package));
            commandService  = commandService ?? throw new ArgumentNullException(nameof(commandService));

            var menuCommandID = new CommandID(CommandSet, CommandId);
            var menuItem      = new MenuCommand(this.Execute, menuCommandID);

            commandService.AddCommand(menuItem);
        }