开发者

Add reference to dll in powershell 2.0

开发者 https://www.devze.com 2023-01-09 03:32 出处:网络
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\")

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")  

But I don't want to use reflection.

Is there a simpl开发者_运维技巧e way to do include my dll without reflection? Something like add reference to this dll?


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

精彩评论

暂无评论...
验证码 换一张
取 消