/// <summary> /// This event handler reports to Visual Studio that the debugger has finished and destroys the program. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Debugger_DebuggingFinished(object sender, EventArgs e) { bps.Clear(); _events.ProgramDestroyed(_node); UiContextUtilities.DeactivateUiContext(_uiContextCookie); }
public PowerShellProjectPackage() { var componentModel = (IComponentModel)GetGlobalService(typeof(SComponentModel)); _validator = (IDependencyValidator)componentModel.GetService <IDependencyValidator>(); UiContextUtilities.ActivateUiContext(UiContextUtilities.CreateUiContext(PowerShellTools.Common.Constants.PowerShellProjectUiContextGuid)); }
int IVsToolWindowFactory.CreateToolWindow(ref Guid toolWindowType, uint id) { UiContextUtilities.ActivateUiContext(UiContextUtilities.CreateUiContext(Constants.PowerShellReplCreationUiContextGuid)); if (toolWindowType == typeof(ReplWindow).GUID) { var model = (IComponentModel)GetService(typeof(SComponentModel)); var replProvider = (ReplWindowProvider)model.GetService <IReplWindowProvider>(); return(replProvider.CreateFromRegistry(model, (int)id) ? VSConstants.S_OK : VSConstants.E_FAIL); } return(VSConstants.E_FAIL); }
/// <summary> /// Asks HostService to find all attachable processes on the given machine. Will prompt user to retry connecting if /// the call to EnumerateRemoteProcesses returns null. /// </summary> /// <param name="remotePort"></param> public void connect(IDebugPort2 remotePort, bool useSSL) { // Make sure user is starting from a local scenario DebugScenario scenario = PowerShellToolsPackage.Debugger.DebuggingService.GetDebugScenario(); if (scenario != DebugScenario.Local) { Log.Debug(string.Format("User is trying to remote attach while already in {0}", scenario)); if (scenario == DebugScenario.RemoteSession) { MessageBox.Show(Resources.AttachExistingRemoteError, Resources.AttachErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Resources.AttachExistingAttachError, Resources.AttachErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // host needs to be initialized before we can connect/enumerate UiContextUtilities.ActivateUiContext(UiContextUtilities.CreateUiContext(Constants.PowerShellReplCreationUiContextGuid)); if (!PowerShellToolsPackage.PowerShellHostInitialized) { // TODO: UI Work required to give user inidcation that it is waiting for debugger to get alive. PowerShellToolsPackage.DebuggerReadyEvent.WaitOne(); } List <KeyValuePair <uint, string> > information; string errorMessage = string.Empty; while (true) { Log.Debug(string.Format("Attempting to find processes on {0}.", _remoteComputer)); information = PowerShellToolsPackage.Debugger.DebuggingService.EnumerateRemoteProcesses(_remoteComputer, ref errorMessage, useSSL); if (information != null) { // information now contains list of processes break; } else if (string.IsNullOrEmpty(errorMessage)) { // user hit cancel return; } else { // error message was returned DialogResult dlgRes = MessageBox.Show(errorMessage, null, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (dlgRes != DialogResult.Retry) { return; } } } foreach (KeyValuePair <uint, string> info in information) { _runningProcesses.Add(new ScriptDebugProcess(remotePort, info.Key, info.Value, _remoteComputer)); } } }
public Engine() { _runspaceSet = new ManualResetEvent(false); _uiContextCookie = UiContextUtilities.CreateUiContext(PowerShellTools.Common.Constants.PowerShellDebuggingUiContextGuid); }
/// <summary> /// This event handler reports to Visual Studio that the debugger has begun /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Debugger_DebuggingBegin(object sender, EventArgs e) { UiContextUtilities.ActivateUiContext(_uiContextCookie); }