Load DLL inside project

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.
Post Reply
klarlichter
Posts: 40
Joined: Tue Nov 19, 2019 1:17 am

Load DLL inside project

Post by klarlichter » Tue Nov 26, 2019 1:43 pm

Hello, we create a project on powershell studio.
till now we call our dll file like: [Reflection.Assembly]::LoadFile("C:\Users\rUser1\Desktop\blabla.dll")
Is it is possible to call that .dll inside project folder? It menas that we not need use absolute path?

It would be great if there is any possibility to call that dll inside project folder like to call another ps1 script inside project folder...

jvierra
Posts: 14000
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Load DLL inside project

Post by jvierra » Tue Nov 26, 2019 2:06 pm

If you mean call it in a script then just add the script folder location to the file name.

$dllfile = Join-Path (Get-ScriptDirectory) blabla.dll
[Reflection.Assembly]::LoadFile($dllfile)

klarlichter
Posts: 40
Joined: Tue Nov 19, 2019 1:17 am

Re: Load DLL inside project

Post by klarlichter » Tue Nov 26, 2019 2:10 pm

I place that dll inside the project and I want create a exe and not roll out my form and dll. Is there are a possibility to call / run that file inside my exe or did I need place the dll as well ?

Like I call inside a psf a ps1 who located inside project i would like call that dll.
Last edited by klarlichter on Tue Nov 26, 2019 2:13 pm, edited 1 time in total.

jvierra
Posts: 14000
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Load DLL inside project

Post by jvierra » Tue Nov 26, 2019 2:12 pm

There is no way to compile an assembly into an EXE. YOu can only copy the assembly to a folder and load it dynamically.

klarlichter
Posts: 40
Joined: Tue Nov 19, 2019 1:17 am

Re: Load DLL inside project

Post by klarlichter » Tue Nov 26, 2019 2:14 pm

Dynamic like you tell above right ?
And could I create a msi who roll out my exe and that dll inside one folder ?

jvierra
Posts: 14000
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Load DLL inside project

Post by jvierra » Tue Nov 26, 2019 2:17 pm

Yes. Just add it as a file to the project and the installer builder will add it to the MSI.

klarlichter
Posts: 40
Joined: Tue Nov 19, 2019 1:17 am

Re: Load DLL inside project

Post by klarlichter » Tue Nov 26, 2019 2:21 pm

Ok. And how create a shortcut automatic to desktop with that exe file ? Is that also possible ?

jvierra
Posts: 14000
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Load DLL inside project

Post by jvierra » Tue Nov 26, 2019 2:55 pm

The are numerous blog articles in the info center that discuss how to option the installer. Start by reading this so you get a complete understanding of the Sapien implementation of the installer technology.

If you continue to have problems with PowerShell Studio I recommend posting in the PowerShell Studio Product Forum for the PowerShell Studio product. The Sapien people will help you with issues about their product.

Post Reply