Question:
When I run the following, PowerShell hangs waiting for the dialog to close, even though the dialog is never displayed:
1 2 3 4 |
[void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' ) $d = New-Object Windows.Forms.OpenFileDialog $d.ShowDialog( ) |
Calling ShowDialog
on a Windows.Forms.Form
works fine. I also tried creating a Form
and passing it as the parent to $d.ShowDialog
, but the result was no different.
Answer:
I was able to duplicate your problem and found a workaround. I don’t know why this happens, but it has happened to others.
If you set the ShowHelp property to $true, you will get the dialog to come up properly.
Example:
1 2 3 4 5 |
[void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' ) $d = New-Object Windows.Forms.OpenFileDialog $d.ShowHelp = $true $d.ShowDialog( ) |
Good Luck!