1

I have a c# dll with custom types that I am using in my scripts. I want to create a class that uses the custom types but I cant seem to import the dll before the class is parsed:

Import-Module CustomModule #contains type CustomType
Class Test
{
    [void]Foo([CustomType]$x)
    {
        ...
    }
}

I get the following error: Unable to find type [CustomType]

But this will work:

Import-Module CustomModule #contains type CustomType
function Foo()
{
    Param(
        [CustomType]$x
    )
    ...
}

I have tried putting the class in a .ps1 and a .psm1 file and both dot-sourcing and using module for importing. Any ideas?

usr1
  • 71
  • 5

0 Answers0