コード例 #1
0
ファイル: ReAttachUi.cs プロジェクト: erlandranvinge/ReAttach
        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;
            }
        }
コード例 #2
0
ファイル: ReAttachUi.cs プロジェクト: erlandranvinge/ReAttach
 private void TryBuildSolution()
 {
     ThreadHelper.JoinableTaskFactory.Run(async() =>
     {
         await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
         var dte = await _package.GetServiceAsync(typeof(SDTE)) as DTE2;
         if (dte == null)
         {
             ReAttachUtils.ShowError("ReAttach failed", "Unable to rebuild solution before build.");
             return;
         }
         try
         {
             dte.Solution.SolutionBuild.Build(true);
         }
         catch (Exception) { }
     });
 }