/// <summary> /// Create a Hyper-V socket connection to the target process and set up /// transport reader/writer. /// </summary> internal override void CreateAsync() { _client = new RemoteSessionHyperVSocketClient(_targetGuid, false, true); if (!_client.Connect(null, String.Empty, false)) { _client.Dispose(); throw new PSInvalidOperationException( PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.ContainerSessionConnectFailed), null, PSRemotingErrorId.ContainerSessionConnectFailed.ToString(), ErrorCategory.InvalidOperation, null); } // Create writer for Hyper-V socket. stdInWriter = new OutOfProcessTextWriter(_client.TextWriter); // Create reader thread for Hyper-V socket. StartReaderThread(_client.TextReader); }
/// <summary> /// Create a Hyper-V socket connection to the target process and set up /// transport reader/writer. /// </summary> internal override void CreateAsync() { _client = new RemoteSessionHyperVSocketClient(_vmGuid, true); if (!_client.Connect(_networkCredential, _configurationName, true)) { _client.Dispose(); throw new PSInvalidOperationException( PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.VMSessionConnectFailed), null, PSRemotingErrorId.VMSessionConnectFailed.ToString(), ErrorCategory.InvalidOperation, null); } // TODO: remove below 3 lines when Hyper-V socket duplication is supported in .NET framework. _client.Dispose(); _client = new RemoteSessionHyperVSocketClient(_vmGuid, false); if (!_client.Connect(_networkCredential, _configurationName, false)) { _client.Dispose(); throw new PSInvalidOperationException( PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.VMSessionConnectFailed), null, PSRemotingErrorId.VMSessionConnectFailed.ToString(), ErrorCategory.InvalidOperation, null); } // Create writer for Hyper-V socket. stdInWriter = new OutOfProcessTextWriter(_client.TextWriter); // Create reader thread for Hyper-V socket. StartReaderThread(_client.TextReader); }