System.Management.Automation和System.Runtime.Remoting程序集

4
我在我的C#应用程序中添加了Assemblies(System.Management.Automation和System.Runtime.Remoting)的引用,并在项目中使用了PowerShell接口。 但是在编译代码时,我遇到了一个错误,它说: "The type or namespace name 'Remoting' does not exist in the namespace 'System.Management.Automation'" The type or namespace name 'PowerShell' could not be found. C:\WINDOWS\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll System.Runtime.Remoting C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Runtime.Remoting.dll"

我认为我们需要知道你正在使用哪个using语句或完整的类名导致了错误...我无法确定为什么它会提到“PowerShell”的类型或命名空间名称。 - Jaykul
1个回答

5

编译时,您应该在此位置引用System.Management.Automation程序集:

C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0

如果您正在寻找PowerShell远程功能,则需要使用System.Management.Automation.Remoting命名空间。 对于PowerShell类型,您可能需要在C#源代码文件中使用以下using语句:

using System.Management.Automation;
using System.Management.Automation.Runspaces;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接