0

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)

KnorxThieus
  • 567
  • 8
  • 17
  • 1
    You need a manifest that specifies the use of v6 of the common controls. Visual Studio should embed this by default; check your project settings to see what is going wrong. – Cody Gray - on strike Aug 18 '16 at 12:26
  • @CodyGray In fact, I had already done so, but after restarting IDE it worked now. Thank you! – KnorxThieus Aug 22 '16 at 09:35

0 Answers0