Build EXE Error message when I try to run it

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 forum is a space to discuss coding involving Graphical User Interfaces (GUI) in PowerShell or using WinForms controls, and technical issues related to development.

- Question about a licensed SAPIEN product? Post here: Product Support for Registered Users
- Question about a trial SAPIEN product? Post here: Former and Future Customers - Questions
This topic is 1 month and 2 weeks 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
CKMHC-it
Posts: 11
Last visit: Wed Jan 08, 2025 7:59 am
Answers: 0

Build EXE Error message when I try to run it

Post by CKMHC-it »

Running the program in Powershell Studio it works but when I build and run the EXE I have gotten these two errors at different times.
Any suggestions?

Could not load file or assembly 'System. Management.Automation,
Version=7.4.6.500, Culture—neutral,
PublicKeyToken=31 bf3856ad3EAe35' Could not find or load a specific
file. (0*80131621)


Cannot load PowerSheII snap-in Microsoft. PowerSheII.Diagnostics
because of the following error: The PowerSheII snap-in module
Sheet\Microsoft.PowerSheII.Commands.Diagnostics.dII does not have
the required PowerSheII snap-in strong name
Microsoft.PowerSheII.Commands.Diagnostics, Version=7.4.5.500,
Culture—neutral, PublicKeyToken=31bf3856ad3EAe35.
User avatar
brittneyr
Site Admin
Posts: 1846
Last visit: Fri Jan 24, 2025 2:10 pm
Answers: 46
Been upvoted: 37 times

Re: Build EXE Error message when I try to run it

Post by brittneyr »

Any packaged exe will instantiate the currently installed PowerShell version. Generally, you should always package for the version installed on a system. As you can see from the error, the package does not actually work on a system that is not matching the packaged version. This is because .NET does not allow 'upscaling' versions, so assembly reference to lower versions cannot use a newer version of an assembly. That is inherent to .NET past the .NET framework Windows PowerShell uses.

Because that is an issue for deploying packages in environments that are not homogenous, we provide "PowerShell runtimes" which can be rolled to have a fixed version reference. A packaged executable will reference the assemblies of the matching runtime (if installed) rather than those of the installed PowerShell version.

Downloads for PowerShell 7 runtimes can be found here:
https://www.sapien.com/support/powershell_7_runtimes
Brittney
SAPIEN Technologies, Inc.
This topic is 1 month and 2 weeks 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