【发布时间】:2020-04-07 15:58:23
【问题描述】:
我目前正在努力将 PowerShell 脚本集成到我的 ASPX Web 表单中,在此过程中,我面临以下问题,这使我无法继续前进,因为由于参考问题,我什至无法构建解决方案强>
a) 从 NuGet 包管理器安装 system.Management.automation,但是安装后我没有看到自动添加的引用,所以我从项目位置手动添加了这个 DLL。不确定这是否不会产生问题,但假设它应该自动添加
b) system.Management.automation 7.0 版本 DLL 需要System.runtime 版本=4.2.2.0,所以我已经安装了 System.运行时 4.3 稳定版。但是当我尝试添加最新版本时,它仍然指向旧的 4.1.2.0 版本并且失败并出现以下错误
> Error CS1705 Assembly 'System.Management.Automation' with identity
> 'System.Management.Automation, Version=7.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35' uses 'System.Runtime,
> Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
> which has a higher version than referenced assembly 'System.Runtime'
> with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a' WebApplication16 C:\Users\****\source\repos\WebApplication16\WebApplication16\Default.aspx.cs 32 Active
以下是我尝试过的东西,它们都不起作用
1) 多次创建新项目
2) 已清理并重建解决方案
3) 尝试在Web.config 中提供bindingRedirect 以使其使用最新版本,但运气不佳
4) 从参考中删除旧版本并尝试添加新系统。运行时版本,但是它将旧版本添加到项目中
有人可以就此提出建议
【问题讨论】: