call external .dll and access .cs methods with powershell

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 12
Joined: Thu Dec 28, 2017 2:05 pm

call external .dll and access .cs methods with powershell

Post by n1mdas » Thu Dec 06, 2018 10:39 am


I am creating a portable exe file that i am able to protect and license accordingly with .
Currently i am looking of ways how to show some licensing details using the C# SDK files.
Could you advise or show me a way of how to best embedded the .dll file along with the .cs file and doing this inside of Powershell? With the demo package the SDK files are shipped and can be reviewed. The idea is to load the .dll file and call the
EntryPoint = "obsGetLicenseStatus"
EntryPoint = "obsGetLicenseExpiration" etc.. within the Powershell GUI to show the license status which is read from an external license.key file.

I tried with the below but seems not possible to run at all:
I found within the Internet the but would like to check how to proceed or do it in the best possible way?


User avatar
Posts: 13128
Joined: Tue May 22, 2007 9:57 am

Re: call external .dll and access .cs methods with powershell

Post by jvierra » Thu Dec 06, 2018 1:28 pm

Is the SDK dll a Net assembly. If so just load it an call it.
If it is a classic Win32 style DLL then you ill need to "P/Invoke" the calls from C# and add the generated type to PS.


You can probably more easily use C# to create a Net assembly wrapper and load that into PS.