PrimalForms – File Dialog Hangs on Windows Vista SP1 with .Net 3.0 /3.5

Some of our PrimalForms users may have encountered issues with the OpenFileDialog or SaveFileDialog running under Windows Vista.

The bad news is that scripts which include OpenFileDialogs or SaveFileDialogs and that previously worked on Windows XP may encounter freezing issues on Vista SP1 systems with .Net 3.0/3.5. The affected scripts will hang when PowerShell executes the File Dialog’s ShowDialog function. It’s important to note that this issue is not limited to PowerShell but may affect any other .Net application.

The good news is that there is a work-around for this issue. In order to prevent this problem, you must set the dialog’s ShowHelp property to $True before calling the ShowDialog function. If you are using SaveFileDialog you will also want to set the CreatePrompt and OverwritePrompt properties to $True as well.

$saveFileDialog1 = New-Object System.Windows.Forms.SaveFileDialog

$saveFileDialog1.ShowHelp = $True

$saveFileDialog1.OverwritePrompt = $True

$saveFileDialog1.CreatePrompt = $True
$saveFileDIalog1.ShowDialog() #It is now safe to call this function

The next version of PrimalForms will set these property values to $True by default; therefore you needn’t worry about setting these properties manually. In addition to solving this issue, the next version of PrimalForms will also prevent the maximized form issue by including a scripted workaround.