FolderBrowserDialog crashing application

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.
Locked
User avatar
gutihz
Posts: 38
Joined: Fri Mar 20, 2015 1:42 pm

FolderBrowserDialog crashing application

Post by gutihz » Thu Oct 26, 2017 10:56 am

Hi Everyone,

In my form I'm having the user select a folder and I get the folder path. When I run my application within the Sapien everything works. But when I build the app and run the executable on another computer everything works except the folder browser dialog. When I click on the button to open the folder browser dialog the application goes in to "not responding" mode.
I tried both "FolderBrowserDialog" and "FolderBrowserModernDialog" with same result.
I tried changing the build settings from V3 to V5 and V2with same result.

here is how I call it

Code: Select all

$btnopenfb_Click={
	
		if ([Void]$fb.ShowDialog() -eq 'OK')
		{
			$txtboxPaths.AppendText($fb.SelectedPath)
			$txtboxPaths.AppendText("`n")
		}
	}
Does anyone know if this is a bug or something?

Thanks in advance.


PowerShell Studio 2017 5.4.145
Version of product: 64
Operating system: Windows 7
OS: 64 bit

User avatar
jvierra
Posts: 13302
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: FolderBrowserDialog crashing application

Post by jvierra » Thu Oct 26, 2017 11:02 am

Be sure to build in STA mode.

User avatar
gutihz
Posts: 38
Joined: Fri Mar 20, 2015 1:42 pm

Re: FolderBrowserDialog crashing application

Post by gutihz » Thu Oct 26, 2017 11:06 am

YOU ARE A FREAKING GENIUS!!!!

I've always wondered how do you know all this s..t. I truly admire you!

User avatar
jvierra
Posts: 13302
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: FolderBrowserDialog crashing application

Post by jvierra » Thu Oct 26, 2017 11:29 am

I have been a developer for more than 30 years and have studied Windows and most other operating systems extensively at the internals level. The stuff just accumulates. I also use a lot of PowerShell and have read all of the current advanced books on PS and continue to refer to them when I am in doubt.

Anyone who puts in sufficient effort can get to where I am and many have gone way past me. Today I meet young programmers out of college for only a couple of years that are way advanced and moving at high speed. They grab new technologies even faster than I can.

All of this is based on your level of interest, curiosity and sweat.

Locked