错误加载System.Management.Automation总成 [英] Error loading System.Management.Automation assembly
问题描述
我正在开发运行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总成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!