Compiled application won't display form

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
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.
This topic is 1 year and 8 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.
pgessford
Posts: 7
Last visit: Fri Sep 09, 2022 10:47 am
Has voted: 1 time

Compiled application won't display form

Post by pgessford »

Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.208
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19044.0
PSVersion: 7.2.2

Working on a very small project that uses a small form and accesses a Password Vault (KeePass) on the local machine. The form will run great in the designer when testing. Upon load ("$Main_Load"), the module "Microsoft.PowerShell.SecretStore" is imported, and the cmdlet "Unlock-SecretVault -name VAULTNAME" prompts the user for a password to unlock the vault, and then accesses the vault, and populates a value in a text field. In the designer, the form prompts the user for the password, and then loads successfully, populating the text field. However, once compiled into an exe in the Packager, the main GUI form doesn't actually display. A prompt appears asking for the vault password, and then the form never displays. Task Manager shows the application running as a local process, but the actual form itself never displays.

I moved the Unlock-SecretVault command to the "$Main_Shown" event, and the form then loads (so we're making progress), prompts the user for the unlock password, and then appears to hang. It never populates the text field. Again, with this modification, it works great in the designer. It falls apart once compiled into an .exe.

Compiled using Script Engine Sapien PowerShell 7.2.2 Host (Windows Forms)

Not sure where to go at this point. I don't understand the disconnect between run in the designer and compiled into executable.

Thanks for any insight you can provide.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Compiled application won't display form

Post by Alexander Riedel »

Are your STA settings in PowerShell Studio and when packaging different?
Alexander Riedel
SAPIEN Technologies, Inc.
pgessford
Posts: 7
Last visit: Fri Sep 09, 2022 10:47 am
Has voted: 1 time

Re: Compiled application won't display form

Post by pgessford »

Thanks for the suggestion. I checked the setting, and STA was enabled in the packager...same as in the designer. Unfortunately, I also attempted compiling and running the app with STA disabled (in both designer and packager) with the same result (runs in the designer but hangs once compiled). Form runs in the designer, but once compiled, no luck.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Compiled application won't display form

Post by Alexander Riedel »

Threading in PowerShell is always tricky.
Try importing the module and prompt for the password before your even create the form object.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 8 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.