ookii-dialogs-winforms
ookii-dialogs-winforms copied to clipboard
Using [Ookii.Dialogs.WinForms.ProgressDialog] in PowerShell 7 causes an immediate crash when ProgressDialog.Show() is called.
I know this isn't the typical use-case of Ookii Dialogs Winforms, but I've had great success using all of the other dialog types in Powershell 7 by loading the assembly in my module and instantiating the various dialog classes. Input Dialog, Password Dialog, and Task Dialog all work great.
Unfortunately, I'm having some trouble diagnosing why the Ookii.Dialogs.WinForms.ProgressDialog
is causing Powershell to explode.
Here is a simple repro script:
$Pdialog = [Ookii.Dialogs.WinForms.ProgressDialog]::new()
$Pdialog.Description = "Cropping SVGs..."
$Pdialog.ShowTimeRemaining = $false
$Pdialog.Text = "Cropping all queued SVGs..."
$Pdialog.WindowTitle = "SVG Crop"
$Pdialog.ProgressBarStyle = 'Marquee'
# Show the dialog
$Pdialog.Show()
Immediately when $Pdialog.Show()
is called, Powershell hard terminates with the following error:
An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.InvalidCastException: Unable to cast COM object of type 'Ookii.Dialogs.WinForms.Interop.ProgressDialogRCW'
to interface type 'Ookii.Dialogs.WinForms.Interop.IProgressDialog'. This operation failed because the QueryInterface call on the COM
component for the interface with IID '{EBBC7C04-315E-11D2-B62F-006097DF5BD4}' failed due to the following error:
No such interface supported (0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Ookii.Dialogs.WinForms.Interop.IProgressDialog.StopProgressDialog()
at Ookii.Dialogs.WinForms.ProgressDialog._backgroundWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
in D:\a\ookii-dialogs-winforms\ookii-dialogs-winforms\src\Ookii.Dialogs.WinForms\ProgressDialog.cs:line 774
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action'1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback'1.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
I will be the first to admit, I have absolutely NO idea what the error message above means.
I did some google-fu, and found here that the CLSID {EBBC7C04-315E-11d2-B62F-006097DF5BD4}
is related to the IProgressDialog
interface.
The error message above reports that the casting of Ookii.Dialogs.WinForms.Interop.ProgressDialogRCW
to IProgressDialog
fails because, well, this: No such interface supported (0x80004002 (E_NOINTERFACE)).
.
No idea how to remedy this.
In one of my scripts I actually did get the Progress Dialog to work. The script was utilizing a standard winforms form, and I created the Progress Dialog instance and called its Show()
method after a button click event.
All of my other scripts fail to show the dialog and crash Powershell.
I am really hoping you could shed some light on what the error message above means, and how I can fix the problem. I really like having the visual feedback in my scripts, and your dialogs are both highly polished and appear native to the OS.
Any help greatly appreciated!
And thank you for creating a great library.