Give error instead of crashing if WSMan client lib not available (#4387)

This commit is contained in:
Steve Lee
2017-07-31 16:26:24 -07:00
committed by Dongbo Wang
parent fa8b9006dd
commit cf9f8c8574
2 changed files with 13 additions and 2 deletions
@@ -2597,7 +2597,15 @@ namespace System.Management.Automation.Remoting.Client
#endif
_handle = IntPtr.Zero;
ErrorCode = WSManNativeApi.WSManInitialize(WSManNativeApi.WSMAN_FLAG_REQUESTED_API_VERSION_1_1, ref _handle);
try
{
ErrorCode = WSManNativeApi.WSManInitialize(WSManNativeApi.WSMAN_FLAG_REQUESTED_API_VERSION_1_1, ref _handle);
}
catch (DllNotFoundException)
{
throw new PSRemotingTransportException(RemotingErrorIdStrings.WSManClientDllNotAvailable);
}
// input / output streams common to all connections
_inputStreamSet = new WSManNativeApi.WSManStreamIDSet_ManToUn(
@@ -1636,7 +1636,10 @@ All WinRM sessions connected to Windows PowerShell session configurations, such
<data name="InvalidRoleCapabilityFileExtension" xml:space="preserve">
<value>The provided role capability file {0} does not have the required .psrc extension.</value>
</data>
<data name="SSHAbruptlyTerminated" >
<data name="SSHAbruptlyTerminated" xml:space="preserve">
<value>The SSH transport process has abruptly terminated causing this remote session to break.</value>
</data>
<data name="WSManClientDllNotAvailable" xml:space="preserve">
<value>This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.</value>
</data>
</root>