MScholtes / PS2EXE

Module to compile powershell scripts to executables
Other
1.24k stars 199 forks source link

The necessary DLL cannot be loaded. #133

Closed saica1101 closed 1 month ago

saica1101 commented 6 months ago

Hello, First of all, thank you for developing this wonderful tool.

I used PS2EXE, but it couldn't load the required DLLs. Why is this happening? スクリーンショット 2024-04-27 111455

スクリーンショット 2024-04-27 111540

The error message is in Japanese, so I translated it as follows: Error: An exception occurred while calling the "LoadFrom" with "1" argument(s): "File or assembly" omitted or one of its dependencies could not be loaded. Operation is not supported. (Exception from HRESULT: 0x80131515)"

The relevant script is as follows: `$AssemblyLocation = Join-Path -Path $ScriptPath -ChildPath assembly foreach ($Assembly in (Get-ChildItem $AssemblyLocation -Filter *.dll)) {

Write-Host $Assembly` }

saica1101 commented 6 months ago

I understand the cause now. First, it was because the necessary DLL was set to block access from external sources. After allowing access from the properties of each DLL, the "DLL load error" no longer occurred. However, the next issue arose when loading the XAML. This seems to occur with PowerShell 5.x, so I used iExpress and compiled it with PowerShell 7.x, which allowed it to start without any issues. "powershell.exe -ExecutionPolicy ByPass script.ps1" -> Does not work "pwsh.exe -ExecutionPolicy ByPass script.ps1" -> Works

So, here's my question: I'm currently compiling with PowerShell 5.x, but in the future, will I compile with PowerShell Core (7.x)? If possible, it would be great to have the option to choose whether to compile with 5.x or 7.x.

MScholtes commented 6 months ago

Hello @saica1101,

Powershell 5.x is installed on every computer with Windows OS and includes a compiler, what are requirements for PS2EXE to work. The presence of Powershell 5 is necessary and guaranteed for the execution of generated executables.

In contrast Powershell Core has to be manually installed and does not contain a compiler. Additionally the compiler libraries for .Net Core - if manually downloaded - have a completely different syntax as the one für .Net 5.x. Powershell Core would have to be installed on every target machine the generated executable should run. This would result in "PS2EXE for Powershell Core" being a new product with new requirements.

Since I don't have the time and knowledge to do this, I would love if someone else would make this new product if it doesn't compete with this project. Really great would be a version that works under Linux too!

Greetings

Markus

MScholtes commented 1 month ago

I assume that the issue no longer exists as there is no feedback.