![](/img/trans.png)
[英]Building a module in C# for Powershell 2 without Visual Studio or access to an SDK
[英]error powershell c# visual studio
我在Visual Studio中有一个简单的类库项目:
using System;
using System.Linq;
using System.Management.Automation;
namespace EdoX_auslesen_xml
{
[Cmdlet(VerbsCommon.Get, "DemoNames")]
public class Get_DemoNames : Cmdlet
{
[Parameter(Mandatory = false)]
public string Prefix;
protected override void ProcessRecord()
{
var names = new string[] { "Chris", "Charlie", "Anne" };
if (string.IsNullOrEmpty(this.Prefix))
{
this.WriteObject(names, true);
}
else
{
var prefixed_names = names.Select(n => this.Prefix + n);
this.WriteObject(prefixed_names, true);
}
}
}
}
当我打开PowerShell尝试“ Get-DemoNames”时,发生错误:
用英语:
Get-DemoNames:找不到文件或类似的“ System.Runtime,版本= 4.2.0.0。文化=中性,PublicKeyToken = b03f5f7f11d50a3a”或它的依赖项。 系统找不到给定的文件。 在行中:1 sign:1 + Get- DemoNames ...
我认为您需要添加对System.Runtime的引用。
查看此 StackOverflow问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.