Add reference to dll in powershell 2.0

后端 未结 1 908
故里飘歌
故里飘歌 2020-12-10 04:18

I created a dll in C# and would like to use it in PowerShell.

I know I can load the dll using:

[Reflection.Assembly]::LoadFile(\"MyDll.dll\")  
         


        
1条回答
  •  借酒劲吻你
    2020-12-10 04:42

    In PowerShell 2.0 the cmdlet Add-Type is designed for this, for example:

    Add-Type -Path "$env:Xyz\bin\Npgsql.dll"
    

    (it’s more likely that under the covers it calls the same LoadFile but this way is more PowerShell-ish)

    0 讨论(0)
提交回复
热议问题