У меня есть простой проект библиотеки классов в 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. Culture = нейтральный, PublicKeyToken = b03f5f7f11d50a3a» или его зависимость не найдена. Система не может найти данный файл.
В строке: 1 знак: 1
+ Get- DemoNames ...