Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add reference to dll in powershell 2.0

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 simple way to do include my dll without reflection? Something like add reference to this dll?

like image 824
Tom Avatar asked Jul 29 '10 09:07

Tom


1 Answers

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)

like image 118
Roman Kuzmin Avatar answered Oct 16 '22 02:10

Roman Kuzmin