gpt4 book ai didi

c# - 我不明白我遇到的 NewNotImplementedException 运行时错误

转载 作者:太空狗 更新时间:2023-10-29 20:39:27 26 4
gpt4 key购买 nike

我正在尝试实现一个远程运行空间,它既需要 connectionInfo 来与 Exchange 对话,又需要一个导入的模块来与事件目录对话。这是问题代码:

runspace = System.Management.Automation.Runspaces.RunspaceFactory.
CreateRunspace(psConnectionInfo);
runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
runspace.Open();

我得到的运行时错误是:

Cannot perform operation because operation "NewNotImplementedException at offset 32 in file:line:column :0:0" is not implemented

如果我省略 runspaceInitialSessionState 行,我不会收到错误,但 ViewEntireForest 的 PowerShell 命令 SetADServerSettings 无法运行,因为无法识别。

堆栈跟踪:

Cannot perform operation because operation "NewNotImplementedException at offset 32 in file:line:column :0:0 " is not implemented. at System.Management.Automation.RemoteRunspace.get_InitialSessionState() at ManageUserForwardsWS.ManageUserForwards.SetExchangeCredentials(String userName, String PwString) in c:\Users\rtanner.CATNET\Documents\Visual Studio 2013\Projects\ManageUserForwardsWS\ManageUserForwardsWS\ManageUserForwards.asmx.cs:line 122

我也可以用这段代码生成同样的错误:

        Pipeline pipeline = runspace.CreatePipeline();

PowerShell powershell = PowerShell.Create();
powershell.Runspace = pipeline.Runspace;

powershell.Runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });

这是 StackTrace:

Cannot perform operation because operation "NewNotImplementedException at offset 32 in file:line:column :0:0" is not implemented. at System.Management.Automation.RemoteRunspace.get_InitialSessionState() at ManageUserForwardsWS.ManageUserForwards.SetForward(String sAMAccountName, String fowardAddress) in c:\Users\rtanner.CATNET\Documents\Visual Studio 2013\Projects\ManageUserForwardsWS\ManageUserForwardsWS\ManageUserForwards.asmx.cs:line 151

这些添加的信息有帮助吗?关于如何解决此问题的任何想法?

最佳答案

据我所知 Microsoft documention Set-AdServerSettings 不是 ActiveDirectory 模块的一部分,而是一个 Exchange CmdLet。

Using Exchange Management Shell Commands With Managed Code文章显示了在 C# 中使用 Set-AdServerSettings CmdLet 必须编写的代码。

关于c# - 我不明白我遇到的 NewNotImplementedException 运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20978865/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com