Skip to main content
 首页 » 编程设计

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

2026年05月04日24findumars

我在我的 C# 应用程序中添加了 Assemblies(System.Management.Automation 和 System.Runtime.Remoting) 的引用,并在我的项目中使用了 powershell 接口(interface)。
但是在编译代码的过程中,我得到一个错误说

"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

请您参考如下方法:

对于编译,您应该在此位置引用 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;