Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using [Ookii.Dialogs.WinForms.ProgressDialog] in PowerShell 7 causes an immediate crash when ProgressDialog.Show() is called. #121

Open
futuremotiondev opened this issue Mar 30, 2024 · 0 comments

Comments

@futuremotiondev
Copy link

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:

VirtualDub64_cPrTUF0OBi

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant