Closed lwsrbrts closed 8 years ago
RequiredAssemblies
part of the manifest to load System.Drawing
but that results in the HueLight
"type" not being found (even though it's a class).So, it seems the only solution when I load my class is to force everyone to go to the trouble of typing
Add-Type -AssemblyName System.Drawing
Import-Module .\PoSHue.ps1
$Light = [HueLight]::new($Name, $IP, $APIKey)
...
That is not good and should not be necessary.
I've no idea why but this seems to now be working using a module manifest and RequiredAssemblies just like I tried before. The class now parses, loads etc. and I can control lights with it.
As a result, I've create a 1.0.0 release, updated the documentation and uploaded the class as a module to the PowerShell Gallery
As a result of the recent introduction of RGBtoXYZ and the use of the [System.Drawing.Color] .NET type, the class will not parse unless the System.Drawing assembly is first loaded.
This means that any script loading the class must first do:
Add-Type -AssemblyName System.Drawing
If you try to run a script/automation without the Add-Type declaration, the class refuses to parse since it can't fine the [System.Drawing.Color] type.
I can't add it to the .ps1 script - it just gives exactly the same error and doesn't load the type.
So, does anyone know how to overcome this in the best way?
Dot source the ps1 script?Turn it in to a module (I had a go but the type still isn't found)