Esempio n. 1
0
        public void OpenClientConnection()
        {
            lock (_syncObject)
            {
                if (_powerShellIntelliSenseService == null || _powerShellDebuggingService == null || _powerShellExplorerService == null)
                {
                    EnsureCloseProcess();
                    var page = PowerShellToolsPackage.Instance.GetDialogPage <GeneralDialogPage>();
                    _hostProcess     = PowershellHostProcessHelper.CreatePowerShellHostProcess(page.Bitness);
                    _process         = _hostProcess.Process;
                    _process.Exited += ConnectionExceptionHandler;

                    // net.pipe://localhost/UniqueEndpointGuid/{RelativeUri}
                    var intelliSenseServiceEndPointAddress = Constants.ProcessManagerHostUri + _hostProcess.EndpointGuid + "/" + Constants.IntelliSenseHostRelativeUri;
                    var deubggingServiceEndPointAddress    = Constants.ProcessManagerHostUri + _hostProcess.EndpointGuid + "/" + Constants.DebuggingHostRelativeUri;
                    var explorerServiceEndPointAddress     = Constants.ProcessManagerHostUri + _hostProcess.EndpointGuid + "/" + Constants.ExplorerHostRelativeUri;

                    try
                    {
                        _intelliSenseServiceChannelFactory          = ChannelFactoryHelper.CreateDuplexChannelFactory <IPowerShellIntelliSenseService>(intelliSenseServiceEndPointAddress, new InstanceContext(PowerShellToolsPackage.Instance.IntelliSenseServiceContext));
                        _intelliSenseServiceChannelFactory.Faulted += ConnectionExceptionHandler;
                        _intelliSenseServiceChannelFactory.Closed  += ConnectionExceptionHandler;
                        _intelliSenseServiceChannelFactory.Open();
                        _powerShellIntelliSenseService = _intelliSenseServiceChannelFactory.CreateChannel();

                        _debuggingServiceChannelFactory          = ChannelFactoryHelper.CreateDuplexChannelFactory <IPowerShellDebuggingService>(deubggingServiceEndPointAddress, new InstanceContext(new DebugServiceEventsHandlerProxy()));
                        _debuggingServiceChannelFactory.Faulted += ConnectionExceptionHandler;
                        _debuggingServiceChannelFactory.Closed  += ConnectionExceptionHandler;
                        _debuggingServiceChannelFactory.Open();
                        _powerShellDebuggingService = _debuggingServiceChannelFactory.CreateChannel();
                        _powerShellDebuggingService.SetRunspace(PowerShellToolsPackage.OverrideExecutionPolicyConfiguration);

                        // TODO: Switch to duplex if Command Explorer can respond to changes in bitness
                        _explorerServiceChannelFactory = ChannelFactoryHelper.CreateChannelFactory <IPowerShellExplorerService>(explorerServiceEndPointAddress);
                        //_explorerServiceChannelFactory = ChannelFactoryHelper.CreateDuplexChannelFactory<IPowerShellExplorerService>(explorerServiceEndPointAddress, new InstanceContext(new ExplorerServiceEventsHandlerProxy()));
                        _explorerServiceChannelFactory.Faulted += ConnectionExceptionHandler;
                        _explorerServiceChannelFactory.Closed  += ConnectionExceptionHandler;
                        _explorerServiceChannelFactory.Open();
                        _powerShellExplorerService = _explorerServiceChannelFactory.CreateChannel();
                    }
                    catch (Exception ex)
                    {
                        // Connection has to be established...
                        Log.Error("Connection establish failed...", ex);
                        EnsureCloseProcess();

                        _powerShellIntelliSenseService = null;
                        _powerShellDebuggingService    = null;
                        throw;
                    }
                }
            }
        }
Esempio n. 2
0
        internal ScriptDebugger(bool overrideExecutionPolicy, IPowerShellDebuggingService debuggingServiceTestHook)
        {
            OverrideExecutionPolicy = overrideExecutionPolicy;
            _debuggingServiceTest   = debuggingServiceTestHook;
            DebuggingService.SetRunspace(overrideExecutionPolicy);

            //TODO: remove once user prompt work is finished for debugging
            _runspace = RunspaceFactory.CreateRunspace();
            _runspace.Open();
            HostUi = new HostUi();

            BreakpointManager = new BreakpointManager();

            NativeMethods.SetForegroundWindow();
        }
Esempio n. 3
0
        public void EnsureClearServiceChannel()
        {
            if (_intelliSenseServiceChannelFactory != null)
            {
                _intelliSenseServiceChannelFactory.Abort();
                _intelliSenseServiceChannelFactory = null;
                _powerShellIntelliSenseService     = null;
            }

            if (_debuggingServiceChannelFactory != null)
            {
                _debuggingServiceChannelFactory.Abort();
                _debuggingServiceChannelFactory = null;
                _powerShellDebuggingService     = null;
            }

            if (_explorerServiceChannelFactory != null)
            {
                _explorerServiceChannelFactory.Abort();
                _explorerServiceChannelFactory = null;
                _powerShellExplorerService     = null;
            }
        }
Esempio n. 4
0
 public PowerShellDebuggingServiceAttachUtilities(IPowerShellDebuggingService service)
 {
     _debuggingService = service;
 }