繁体   English   中英

错误的PowerShell C#Visual Studio中

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM