I'm using C# service to execute Powershell commands on a remote machine and show the results. I'm using C# library System.Management.Automation.Runspaces to executing the commands on remote system.
On one of the server, TypeInitializationException has occured while creating Runspace and the service is crashed.
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://" + server + "/powershell"), strShellUri, cred);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
runspace = RunspaceFactory.CreateRunspace(connectionInfo);
Even after we capture the exception in try-catch block, the service is crashed. On googling, the exception is triggered by Inner Exception.
InnerException: System.EntryPointNotFoundException
Message=Unable to find an entry point named 'WSManInitialize' in DLL 'WsmSvc.dll'. StackTrace: at System.Management.Automation.Remoting.Client.WSManNativeApi.WSManInitialize(Int32 flags, IntPtr& wsManAPIHandle) at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager. WSManAPIStaticData..ctor() at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager ..cctor()
How can i resolve the inner exception issue.