Product, version and build:PowerShell Studio 2021 5.8.191.0
Operating system: Windows Server 2019
PowerShell version(s): 7.1.3
Hello,
I'm trying to make a .exe with PowerShell Studio 2021 and Powershell 7, it's a Windows Form.
I'm able to build it, but when I try to start the .exe file on my dev computer or on my own computer it always return this error:
Could not load file or assembly 'System.Management.Automation, Version=7.1.3.0, Culture = neutral, PublicKeyToken=31bf3856ad364e35'.
Could not find or load a specific file. (0x80131621)
I was starting to think there was an issue in my script, so I created a new Windows Form, Dialog style, builded it right away and got the same result.
The form is able to be executed inside Sapien but fail when packaged in .exe.
I've tried to install the PowerShell 7 Runtimes from Sapien, the .NET 5, .NET Core 3.1 and .NET Desktop 3.1 I found at microsoft but it still doesn't work.
Am i missing something or is it just not compatible ATM?
Best Regards,
Mathis.
Powershell 7: Script doesn't work when packaged in .exe (0x80131621)
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 2
- Last visit: Sat Apr 22, 2023 12:49 pm
Re: Powershell 7: Script doesn't work when packaged in .exe (0x80131621)
With .NET and PowerShell 7, a packaged application is not a single file. The folder containing the application file is considered the actual application. This means all the additional files in that folder are required for the packaged script to run.
It also means when deploying this to other machines, the specific version of PowerShell and .NET are needed on that machine for your packaged executable to run. We do provide runtimes that will allow applications to run on machines without that specific PowerShell 7 version installed: For more information about this, I recommend reading the following article:
https://www.sapien.com/blog/2020/08/12/ ... -net-core/
Are you able to run you build and run your exe through PowerShell Studio or SAPIEN Script Packager:
It also means when deploying this to other machines, the specific version of PowerShell and .NET are needed on that machine for your packaged executable to run. We do provide runtimes that will allow applications to run on machines without that specific PowerShell 7 version installed: For more information about this, I recommend reading the following article:
https://www.sapien.com/blog/2020/08/12/ ... -net-core/
Are you able to run you build and run your exe through PowerShell Studio or SAPIEN Script Packager:
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
-
- Posts: 2
- Last visit: Sat Apr 22, 2023 12:49 pm
Re: Powershell 7: Script doesn't work when packaged in .exe (0x80131621)
Hello Brittney,
Thank you for your answer. Your link is really interesting!
I've tried to Build & Run and it's working, so i've tried to start my packaged app directly and it's working too.
Is it possible that the issue was present because I was starting the app from my remote drive ? I did some modification on my ExecutionPolicy yesterday as a workaround for another issue with another script, but I did not tried again to start this package until now.
Also, does Powershell 7 Windows Service is planned to be available in the future, and which OS is supported by the runtimes?
Best Regards,
Mathis.
Thank you for your answer. Your link is really interesting!
I've tried to Build & Run and it's working, so i've tried to start my packaged app directly and it's working too.
Is it possible that the issue was present because I was starting the app from my remote drive ? I did some modification on my ExecutionPolicy yesterday as a workaround for another issue with another script, but I did not tried again to start this package until now.
Also, does Powershell 7 Windows Service is planned to be available in the future, and which OS is supported by the runtimes?
Best Regards,
Mathis.
Re: Powershell 7: Script doesn't work when packaged in .exe (0x80131621)
The computer that is running the executable is where the .NET version and PowerShell version (whether it is the full PowerShell install or our runtimes). In the past, .NET applications did not run from an untrusted source like a network drive. This could be the problem.
You may find the following links helpful:
https://social.msdn.microsoft.com/Forum ... m=netfxbcl
https://docs.microsoft.com/en-us/dotnet ... full-trust
At this point in time, there are no plans in motion for a SAPIEN PowerShell 7 Windows Service engine for packaging.
The runtimes support the same operating systems that our products support:
Windows Server 2016 / 2019 or Windows 10, 64-bit versions supported
You may find the following links helpful:
https://social.msdn.microsoft.com/Forum ... m=netfxbcl
https://docs.microsoft.com/en-us/dotnet ... full-trust
At this point in time, there are no plans in motion for a SAPIEN PowerShell 7 Windows Service engine for packaging.
The runtimes support the same operating systems that our products support:
Windows Server 2016 / 2019 or Windows 10, 64-bit versions supported
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.