To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build: PowerShell Studio, 5.5.153_062918_x64
32 or 64 bit version of product: 84 bit
Operating system: Windows 10
32 or 64 bit OS: 64 bit
*** Please add details and screenshots as needed below. ***
I am working on a GUI script that has a code block that initiates an Azure storage blob copy and then shows an update about the percentage completion. The issue I am facing is that when the GUI script is compiled with Windows Forms as a build engine, the cmdlet Start-AzureStorageBlobCopy hangs.
There are no errors thrown. Everything works okay while running the script in debug mode in the IDE. On the other hand, if the script engine is set to Windows Application, everything works okay.
Could someone help? It is
GUI Script Hang with specific build engine.
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.
- milindnaphade
- Posts: 10
- Last visit: Thu Apr 21, 2022 11:00 pm
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: GUI Script Hang with specific build engine.
Did you try enabling STA mode when packaging with the Forms engine?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- milindnaphade
- Posts: 10
- Last visit: Thu Apr 21, 2022 11:00 pm
Re: GUI Script Hang with specific build engine.
Yes. The Use STA Mode (Recommended for GUI Scripts) is checked by default.
Even Windows Application as build engine would be perfect for me as far someone could suggest a way to hide a console Window that pops up at the time of compiled EXE execution.
Even Windows Application as build engine would be perfect for me as far someone could suggest a way to hide a console Window that pops up at the time of compiled EXE execution.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: GUI Script Hang with specific build engine.
Ok, now I am confused. If you package (its not a compiler) for Windows Application, there should be no console.
Maybe we should see some screenshots of the settings and what you see when you run it.
Maybe we should see some screenshots of the settings and what you see when you run it.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- milindnaphade
- Posts: 10
- Last visit: Thu Apr 21, 2022 11:00 pm
Re: GUI Script Hang with specific build engine.
Thanks for the correction. Yes, it is the packager.
When Windows Application is selected as a Packager. It renders a pop-up console as shown in the below screenshot.
and here are the packager settings
When Windows Application is selected as a Packager. It renders a pop-up console as shown in the below screenshot.
and here are the packager settings
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: GUI Script Hang with specific build engine.
Ah, yes, that is not a console. That is the actual host window. I am not sure why this one would work and the forms one would not, but I will look at the code and see what I can find out.
Try this in your code, best probably in your event handler when you show YOUR form.
$Window = $SAPIENHost.GetMainForm()
$Window.Visible = $false
This will only have an effect on the packaged executable. It might not work. It's just an experiment.
Try this in your code, best probably in your event handler when you show YOUR form.
$Window = $SAPIENHost.GetMainForm()
$Window.Visible = $false
This will only have an effect on the packaged executable. It might not work. It's just an experiment.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- milindnaphade
- Posts: 10
- Last visit: Thu Apr 21, 2022 11:00 pm
Re: GUI Script Hang with specific build engine.
Well, that did not work
Any other options. If it helps, the whole code worked just fine until a few days ago. I guess I am seeing a lot of issues after updating the PSStudio version to 5.5.153_062918. On the other hand, degrading the PS Studio version does not help any longer.
Code: Select all
Method invocation failed because [.] does not contain a method named 'GetMainForm'.
At line:783 char:3
+ $Window = $SAPIENHOST.GetMainForm()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
The property 'Visible' cannot be found on this object. Verify that the property exists and can be set.
At line:784 char:3
+ $Window.Visible = $false
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: GUI Script Hang with specific build engine.
As I said, it might not work. The Forms engine has not really changed for quite some time, and since it works in the other host and while running it from PowerShell Studio there is likely something else at play.
It is quite possible and it would not be the first time that a Windows Update or a framework update screwed something up.
I will investigate on Monday.
It is quite possible and it would not be the first time that a Windows Update or a framework update screwed something up.
I will investigate on Monday.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- milindnaphade
- Posts: 10
- Last visit: Thu Apr 21, 2022 11:00 pm
Re: GUI Script Hang with specific build engine.
Excellent. Thank you for the help.
BTW, I could work around the issue by using something like below:
With this, the host process won't close upon form closing though. So I added another piece of code on Form Closed event.
I definitely have adequate measures in place to prevent any data loss before killing the host process. If you believe an update would have messed up things (I agree that could be a possibility. Updates are known to mess up things quite often ) I am happy to provide machine information with all the configuration settings. It would at least help avoiding issues for others
BTW, I could work around the issue by using something like below:
Code: Select all
Add-Type -Name win -MemberDefinition '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);' -Namespace native
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle,0)
Code: Select all
$CurrentProc = [System.Diagnostics.Process]::GetCurrentProcess()
$CurrentProc.Kill()
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: GUI Script Hang with specific build engine.
Yeah, that really is a hack so to speak
I will look what the differences are because it really puzzles me why one engine would work and not the other.
I will look what the differences are because it really puzzles me why one engine would work and not the other.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.