1

I have got a simple class libary project in 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);
            }

        }
    }

}

When I open PowerShell an try to "Get-DemoNames" an error occurs:

enter image description here

in English:

Get-DemoNames: the file or assebly "System.Runtime, Version=4.2.0.0. Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or a dependency of it was not found. The system cannot find the given file. In line:1 sign:1 + Get- DemoNames...

Anne Martin
  • 69
  • 1
  • 10
  • The error message in the image is in German. Also paste text, not images. – Kristoffer Jälén Jun 26 '18 at 09:19
  • Get-DemoNames: the file or assebly "System.Runtime, Version=4.2.0.0. Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or a dependency of it was not found. The system cannot find the given file. – Anne Martin Jun 26 '18 at 09:23
  • What if one of the users that wanted to help doesn't understand the language that the error message is displaying in :/ please add English translation for the error to get more users to help :) – Ali Ezzat Odeh Jun 26 '18 at 09:23
  • try copying System.Runtime.dll next to exe – Ali Ezzat Odeh Jun 26 '18 at 09:33
  • I added it to the Assemblies but it hasn't help – Anne Martin Jun 26 '18 at 09:37
  • Your code is failing to get a dependency assembly. Try to reduce them to the minimal possible, set all of them to copy to the result folder, and check if after that same error occurs. – Cleptus Jun 26 '18 at 09:46

1 Answers1

0

I think you need to add a reference to System.Runtime.

View this StackOverflow question.

Spirit Pony
  • 148
  • 7