Using Joey , you can use this function to set "aliases" to assemblies. It basically assigns a function assembly with the name of the given alias that you want.
function Global:Add_Assembly_Alias($STR_assembly, $alias) { [string]$assembly = "$STR_assembly.{0}" $ExecutionContext.InvokeCommand.InvokeScript( $ExecutionContext.InvokeCommand.NewScriptBlock(" function Global:$alias(`$namespace) { [string](`"$assembly`" -f `$namespace) } ") ) }
eg. if you want to assign forms to System.Windows.Forms forms, you would name the main function as
Add_Assembly_Alias System.Windows.Forms wforms
It generates a "wforms" function with a namespace as an argument, which you can use to add new objects, etc. If you want to add, for example, a text field object, you just need to call
$tb = new-object (wforms TextBox)
It is not so much, but I think it is so close that you can assign the assembly to what is similar to an alias. Unfortunately, I was not able to impose this for direct form calls
[Windows.Forms.MessageBox]::Show("Hello World!")
but I hope this still helps.
Cheers d
sedsiv
source share