错误加载System.Management.Automation总成

编程入门 行业动态 更新时间:2024-10-28 12:31:12
本文介绍了错误加载System.Management.Automation总成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发运行PowerShell脚本WPF应用程序。

I am developing a WPF application which is running a powershell script.

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

我已经添加下面的汇编。

I have added the following assembly.

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

但是,当程序运行以下异常来;

But when program runs following exception comes;

无法加载文件或程序集System.Management.Automation,版本= 3.0.0.0,文化=中性公钥= 31bf3856ad364e35或它的一个依赖。强名称验证失败。 (从HRESULT异常:0x8013141A):System.Management.Automation,版本= 3.0.0.0,文化=中性公钥= 31bf3856ad364e35} **

Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)":"System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}**

当我搜索这个错误,我可以找到一些答案。但这些都不清楚,我请咨询我。

When I search this error I can find some answers. But those are not clear for me. Please advice me.

推荐答案

最后我能解决我的问题,这是我做什么,结果打开我的 .csproj的文件的结果搜索对于System.Management.Automation参考结果替换具有以下<参考包括=System.Management.Automation/> 这些步骤固定我的问题。

Finally I was able to fix my issue. This is what I does; open my .csproj file search for System.Management.Automation reference. Replace that with the following <Reference Include="System.Management.Automation" /> These steps fixed my issue

更多推荐

错误加载System.Management.Automation总成

本文发布于:2023-11-08 22:22:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1570609.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:总成   加载   错误   System   Automation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!