public void Execute(object sender, EventArgs e)
        {
            var dte = (EnvDTE.DTE)_visualStudioPackageProvider.Package.DTE; //GetService(typeof(EnvDTE.DTE));

              var uiShell = _visualStudioPackageProvider.Package.VsUIShell;
              var parentHwnd = IntPtr.Zero;
              uiShell.GetDialogOwnerHwnd(out parentHwnd);

              var parentShim = new NativeWindow();
              parentShim.AssignHandle(parentHwnd);
              var dialog = new AttachDialog();
              var result = dialog.ShowDialog(parentShim);
              if (result == DialogResult.OK) {
            HashSet<Process> processes = new HashSet<Process>();
            foreach (int pid in dialog.SelectedItems) {
              Process p = Process.GetProcessById(pid);
              if (!p.IsBeingDebugged())
            processes.Add(p);

              if (dialog.AutoAttachToCurrentChildren) {
            foreach (Process child in p.GetChildren()) {
              if (!child.IsBeingDebugged())
                processes.Add(child);
            }
              }
            }
            List<Process> processList = new List<Process>(processes);
            ChildDebuggingMode mode = (dialog.AutoAttachToFutureChildren)
            ? ChildDebuggingMode.AlwaysAttach
            : ChildDebuggingMode.UseDefault;
            DebugAttach.AttachToProcess(processList.ToArray(), mode);
              }
        }
        public void Execute(object sender, EventArgs e)
        {
            var dte = (EnvDTE.DTE)_visualStudioPackageProvider.Package.DTE; //GetService(typeof(EnvDTE.DTE));

            var uiShell    = _visualStudioPackageProvider.Package.VsUIShell;
            var parentHwnd = IntPtr.Zero;

            uiShell.GetDialogOwnerHwnd(out parentHwnd);

            var parentShim = new NativeWindow();

            parentShim.AssignHandle(parentHwnd);
            var dialog = new AttachDialog();
            var result = dialog.ShowDialog(parentShim);

            if (result == DialogResult.OK)
            {
                HashSet <Process> processes = new HashSet <Process>();
                foreach (int pid in dialog.SelectedItems)
                {
                    Process p = Process.GetProcessById(pid);
                    if (!p.IsBeingDebugged())
                    {
                        processes.Add(p);
                    }

                    if (dialog.AutoAttachToCurrentChildren)
                    {
                        foreach (Process child in p.GetChildren())
                        {
                            if (!child.IsBeingDebugged())
                            {
                                processes.Add(child);
                            }
                        }
                    }
                }
                List <Process>     processList = new List <Process>(processes);
                ChildDebuggingMode mode        = (dialog.AutoAttachToFutureChildren)
            ? ChildDebuggingMode.AlwaysAttach
            : ChildDebuggingMode.UseDefault;
                DebugAttach.AttachToProcess(processList.ToArray(), mode);
            }
        }