我正在开发运行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总成
发布评论