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.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Load DLL inside project

Post by klarlichter »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Load DLL inside project

Post by jvierra »

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
Last visit: Sun Jan 16, 2022 3:44 am

Re: Load DLL inside project

Post by klarlichter »

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 1:13 pm, edited 1 time in total.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Load DLL inside project

Post by jvierra »

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
Last visit: Sun Jan 16, 2022 3:44 am

Re: Load DLL inside project

Post by klarlichter »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Load DLL inside project

Post by jvierra »

Yes. Just add it as a file to the project and the installer builder will add it to the MSI.
klarlichter
Posts: 40
Last visit: Sun Jan 16, 2022 3:44 am

Re: Load DLL inside project

Post by klarlichter »

Ok. And how create a shortcut automatic to desktop with that exe file ? Is that also possible ?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Load DLL inside project

Post by jvierra »

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.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked