[英]I don't understand the NewNotImplementedException runtime error I'm getting
我正在嘗試實現一個遠程運行空間,它需要connectionInfo與Exchange通信,導入模塊需要與活動目錄通信。 這是問題代碼:
runspace = System.Management.Automation.Runspaces.RunspaceFactory.
CreateRunspace(psConnectionInfo);
runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
runspace.Open();
我得到的運行時錯誤是:
無法執行操作,因為操作“文件中的偏移32處的NewNotImplementedException:line:column:0:0”未實現
如果省略runspaceInitialSessionState
行,我不會收到錯誤,但PowerShell命令SetADServerSettings
到ViewEntireForest無法運行,因為它無法識別。
堆棧跟蹤:
無法執行操作,因為未實現操作“文件中的偏移32處的NewNotImplementedException:line:column:0:0”。 在System.Management.Automation.RemoteRunspace.get_InitialSessionState()位於c:\\ Users \\ rtanner.CATNET \\ Documents \\ Visual Studio 2013 \\ Projects \\ ManageUserForwardsWS \\ ManageUserForwardsWS \\ ManageUserForwards.asmx中的ManageUserForwardsWS.ManageUserForwards.SetExchangeCredentials(String userName,String PwString) .cs:第122行
我也可以使用此代碼生成相同的錯誤:
Pipeline pipeline = runspace.CreatePipeline();
PowerShell powershell = PowerShell.Create();
powershell.Runspace = pipeline.Runspace;
powershell.Runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
這是StackTrace:
無法執行操作,因為未實現操作“文件中的偏移32處的NewNotImplementedException:line:column:0:0”。 在System.Management.Automation.RemoteRunspace.get_InitialSessionState()位於c:\\ Users \\ rtanner.CATNET \\ Documents \\ Visual Studio 2013 \\ Projects \\ ManageUserForwardsWS \\ ManageUserForwardsWS \\ ManageUserForwards.asmx中的ManageUserForwardsWS.ManageUserForwards.SetForward(String sAMAccountName,String fowardAddress) .cs:第151行
這個附加信息有幫助嗎? 有想法該怎么解決這個嗎?
據我所知,在Microsoft文檔中, Set-AdServerSettings
不是ActiveDirectory
模塊的一部分,而是Exchange CmdLet。
使用帶有托管代碼的Exchange命令行管理程序命令文章顯示了您必須編寫的代碼,以便在C#中使用Set-AdServerSettings
CmdLet。
遠程Runspace構造函數不初始化並使用InitialSessionState對象。 它僅適用於本地運行空間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.