PowerShell - Set Alias for Loaded Assembly

前端 未结 4 763
傲寒
傲寒 2021-02-09 00:25

I use this code to load a .Net assembly to PowerShell:

[System.Reflection.Assembly]::Load(\"System.Windows.Forms, Version=2.0.0.0, Culture=neutral, Publ         


        
4条回答
  •  无人共我
    2021-02-09 00:47

    You can store the type in variable and use the variable

    $forms = [System.Windows.Forms.MessageBox]
    $forms::Show('Hello')
    

    And in this case you can load the assembly like this:

    Add-Type –assembly system.windows.forms
    

提交回复
热议问题