I love TaskDialogs and quite often use them, but I have trouble invoking them outside of Windows Form class.
In a Winforms class, they can be invoked easy like this:
new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog().Show();
So to show a general error message if any exception is thrown while running my application, I wrote the same line into static Program.Main()
:
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
catch (Exception exception)
{
// TODO: Show error message here
new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog().Show();
}
But when this dialog should be shown, I get a NotSupportedException
at .Show()
:
TaskDialog feature needs to load version 6 of comctl32.dll but a different version is current loaded in memory.
app.manifest
defining the assemblyIdentity
version to 6.0 is included to project file.
I did some research and found out the TaskDialog could require an ApplicationContext
, but I don't know how to pass a non-Windows.Form
object to it.
How can I workaround this issue? Thanks for any suggestions!
(Regarding frequent issues with TaskDialog, I tested this on different NuGet versions of WindowsAPICodePack
with same result. For best reproduce: Install-Package WindowsAPICodePack-Core
and Shell
. Regards)