private void ReAttachCommandClicked(object sender, EventArgs e) { var command = sender as OleMenuCommand; if (command == null) { ReAttachUtils.ShowError("ReAttach failed.", "Click was sent from non-ole command."); return; } var index = command.CommandID.ID - ReAttachConstants.ReAttachCommandId; var unAttachedTargets = _history.GetUnAttached(); var target = index < unAttachedTargets.Length ? unAttachedTargets[index] : null; if (target == null) { return; } if (_options.BuildBeforeReAttach) { TryBuildSolution(); } if (!EnsureDebuggerService()) { ReAttachUtils.ShowError("ReAttach failed.", "Unable to obtain ref to debugger service."); return; } var result = _debugger.ReAttach(target); if (result == ReAttachResult.NotStarted) { var dialog = new WaitingDialog(_debugger, target); dialog.ShowModal(); result = dialog.Result; } switch (result) { case ReAttachResult.Success: break; case ReAttachResult.ElevationRequired: ReAttachUtils.ShowElevationDialog(); break; case ReAttachResult.NotStarted: ReAttachUtils.ShowError("ReAttach failed.", "Process not started."); break; case ReAttachResult.Cancelled: break; case ReAttachResult.Failed: ReAttachUtils.ShowError("ReAttach failed.", "Failed reattaching to process."); break; } }