【问题标题】:Error loading System.Management.Automation assembly加载 System.Management.Automation 程序集时出错
【发布时间】:2013-07-04 06:54:54
【问题描述】:

我正在开发一个运行 powershell 脚本的 WPF 应用程序。

string scriptPath = "/script/myscript.ps1";
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scriptPath);
Collection<PSObject> results = pipeline.Invoke();  

我添加了以下程序集。

C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll

但是当程序运行时出现异常;

无法加载文件或程序集“System.Management.Automation,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。强名称验证失败。 (HRESULT 异常:0x8013141A)":"System.Management.Automation,版本=3.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35"}**

当我搜索这个错误时,我可以找到一些答案。但这些对我来说并不清楚。 请给我建议。

【问题讨论】:

    标签: c# wpf powershell assemblybinding


    【解决方案1】:

    我终于能够解决我的问题。这就是我所做的;
    打开我的 .csproj 文件
    搜索 System.Management.Automation 参考。
    将其替换为以下 &lt;Reference Include="System.Management.Automation" /&gt;
    这些步骤解决了我的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      • 2015-02-15
      • 2023-01-11
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多