locked
Unable to find type[ ]: make sure that the assembly containing this type is loaded. RRS feed

  • Question

  • I created an Enum, and while trying to run it by running the command [MyNamespace.MyEnum], I get the error that says "Unable to find type[MyNamespace.MyEnum]: make sure that the assembly containing this type is loaded." This is what my enum looks like

    $enum = "
    namespace MyNamespace
    {
        public enum MyEnum
       {
          value1 = 0, value2 = 1
       }
    }
    "
    
    Add-Type -TypeDefinition $enum -Language CSharp

    Does anyone have an idea why I keep getting this error? I really appreciate the suggestions. Thanks.

    Friday, March 28, 2014 8:38 PM

Answers

  • Thanks for that feedback Peter Ziganki....I actually just got it to work as well. I had to run the code first to load it before running that command. Sorry I am new to PowerShell, so am making serious newbie mistakes:)

    Thanks.

    • Edited by Spawn10 Friday, March 28, 2014 9:45 PM
    • Marked as answer by Spawn10 Wednesday, April 2, 2014 4:16 PM
    Friday, March 28, 2014 9:31 PM

All replies

  • This code works for me as user and as admin. I have powershell 4.0
    Friday, March 28, 2014 9:06 PM
  • Thanks for that feedback Peter Ziganki....I actually just got it to work as well. I had to run the code first to load it before running that command. Sorry I am new to PowerShell, so am making serious newbie mistakes:)

    Thanks.

    • Edited by Spawn10 Friday, March 28, 2014 9:45 PM
    • Marked as answer by Spawn10 Wednesday, April 2, 2014 4:16 PM
    Friday, March 28, 2014 9:31 PM