private Runspace CreateNamedPipeRunspace(NamedPipeConnectionInfo connectionInfo) { TypeTable typeTable = TypeTable.LoadDefaultTypeFiles(); RemoteRunspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo, this.Host, typeTable) as RemoteRunspace; remoteRunspace.Name = NamedPipeRunspaceName; remoteRunspace.ShouldCloseOnPop = true; _connectingRemoteRunspace = remoteRunspace; try { remoteRunspace.Open(); remoteRunspace.Debugger?.SetDebugMode(DebugModes.LocalScript | DebugModes.RemoteScript); } catch (RuntimeException e) { // Unwrap inner exception for original error message, if any. string errorMessage = (e.InnerException != null) ? (e.InnerException.Message ?? string.Empty) : string.Empty; if (connectionInfo.CustomPipeName != null) { ThrowTerminatingError( new ErrorRecord( new RuntimeException( StringUtil.Format( RemotingErrorIdStrings.EnterPSHostProcessCannotConnectToPipe, connectionInfo.CustomPipeName, errorMessage), e.InnerException), "EnterPSHostProcessCannotConnectToPipe", ErrorCategory.OperationTimeout, this)); } else { string msgAppDomainName = connectionInfo.AppDomainName ?? NamedPipeUtils.DefaultAppDomainName; ThrowTerminatingError( new ErrorRecord( new RuntimeException( StringUtil.Format( RemotingErrorIdStrings.EnterPSHostProcessCannotConnectToProcess, msgAppDomainName, connectionInfo.ProcessId, errorMessage), e.InnerException), "EnterPSHostProcessCannotConnectToProcess", ErrorCategory.OperationTimeout, this)); } } finally { _connectingRemoteRunspace = null; } return(remoteRunspace); }
private Runspace CreateNamedPipeRunspace(int procId, string appDomainName) { NamedPipeConnectionInfo connectionInfo = new NamedPipeConnectionInfo(procId, appDomainName); return(CreateNamedPipeRunspace(connectionInfo)); }
internal NamedPipeClientSessionTransportManager( NamedPipeConnectionInfo connectionInfo, Guid runspaceId, PSRemotingCryptoHelper cryptoHelper) : base(connectionInfo, runspaceId, cryptoHelper, _threadName) { if (connectionInfo == null) { throw new PSArgumentNullException("connectionInfo"); } _connectionInfo = connectionInfo; }
private Runspace CreateNamedPipeRunspace(string customPipeName) { NamedPipeConnectionInfo connectionInfo = new NamedPipeConnectionInfo(customPipeName); return(CreateNamedPipeRunspace(connectionInfo)); }
private Runspace CreateNamedPipeRunspace(int procId, string appDomainName) { NamedPipeConnectionInfo connectionInfo = new NamedPipeConnectionInfo(procId, appDomainName); TypeTable typeTable = TypeTable.LoadDefaultTypeFiles(); RemoteRunspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo, this.Host, typeTable) as RemoteRunspace; remoteRunspace.Name = NamedPipeRunspaceName; remoteRunspace.ShouldCloseOnPop = true; _connectingRemoteRunspace = remoteRunspace; try { remoteRunspace.Open(); remoteRunspace.Debugger.SetDebugMode(DebugModes.LocalScript | DebugModes.RemoteScript); } catch (RuntimeException e) { string msgAppDomainName = (!string.IsNullOrEmpty(appDomainName)) ? appDomainName : NamedPipeUtils.DefaultAppDomainName; // Unwrap inner exception for original error message, if any. string errorMessage = (e.InnerException != null) ? (e.InnerException.Message ?? string.Empty) : string.Empty; ThrowTerminatingError( new ErrorRecord( new RuntimeException( StringUtil.Format(RemotingErrorIdStrings.EnterPSHostProcessCannotConnectToProcess, msgAppDomainName, procId, errorMessage), e.InnerException), "EnterPSHostProcessCannotConnectToProcess", ErrorCategory.OperationTimeout, this)); } finally { _connectingRemoteRunspace = null; } return remoteRunspace; }