Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I access My Custom .NET Class from PowerShell?

I have a couple of questions and doubts to regarding PowerShell and .NET Classes.

I am trying to write a class 'foo' that will call Rest web service and perform some tasks. If I deploy the class in GAC then can I call it from PowerShell?

like image 541
Mitul Avatar asked Feb 09 '12 14:02

Mitul


2 Answers

Try:

ADD-TYPE -AssemblyName myassemblyname

or

[System.Reflection.Assembly]::LoadWithPartialName("myassemblyname")

to access method/properties of your assembly you can do this:

[myassemblyname]::mymethod()
[myassemblyname]::myproperty
like image 58
CB. Avatar answered Nov 14 '22 21:11

CB.


You can load your assembly with the Add-Type cmdlet or with System.Reflection.Assembly class and then you can use the New-Object cmdlet to create objects from your assembly classes.

like image 37
Shay Levy Avatar answered Nov 14 '22 21:11

Shay Levy