C#サービスを使用して、リモートマシンでPowershellコマンドを実行し、結果を表示しています。C#ライブラリSystem.Management.Automation.Runspacesを使用して、リモートシステムでコマンドを実行しています。
サーバーの1つで、Runspaceの作成中にTypeInitializationExceptionが発生し、サービスがクラッシュしました。
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://" + server + "/powershell"), strShellUri, cred);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
runspace = RunspaceFactory.CreateRunspace(connectionInfo);
try-catchブロックで例外をキャプチャした後でも、サービスはクラッシュします。グーグルでは、例外は内部例外によってトリガーされます。
InnerException:System.EntryPointNotFoundException
メッセージ=DLL「WsmSvc.dll」で「WSManInitialize」という名前のエントリポイントが見つかりません。StackTrace:System.Management.Automation.Remoting.Client.WSManNativeApi.WSManNativeApi.WSManInitialize(Int32 flags、IntPtr&wsManAPIHandle)atSystem.Management.Automation.Remoting.Client.WSManClientSessionTransportManager。System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager ..cctor()のWSManAPIStaticData..ctor()
内部例外の問題を解決するにはどうすればよいですか。