2

We have an older WPF application that makes use of the "Windows API Code Pack" in order to show a Task Dialog (something that was introduced back in Vista but worked all the way through Windows 8).

I'm now trying to run the project on Windows 10, and when I try to show the Task Dialog, I get the following exception:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Microsoft.WindowsAPICodePack.Dialogs.TaskDialogNativeMethods.TaskDialogIndirect (TaskDialogConfiguration taskConfig, Int32& button, Int32& radioButton, Boolean& verificationFlagChecked)
at Microsoft.WindowsAPICodePack.Dialogs.NativeTaskDialog.NativeShow()
at Microsoft.WindowsAPICodePack.Dialogs.TaskDialog.ShowCore()

Are these APIs no longer available in Windows 10?

Is there a replacement with similar functionality that is available in Windows 10 without writing a custom dialog?

Edit: I got it to run (sheer luck I guess? I didn't change any code) and the dialog popped up like this:

Win10 Task Dialog

There should be 3 buttons, and definitely no Chinese characters, so I would agree with the exception that there is definitely some memory issue going on here. Any ideas?

qJake
  • 16,821
  • 17
  • 83
  • 135
  • The "chinese" characters may hint that there is a problem with string encodings, either in your code or in the library. – Alejandro Oct 19 '17 at 20:21
  • @Alejandro Since I have not worked on this application recently, and it used to work a few years ago, I would bet there's an issue in the library (which hasn't been updated in many years). :) My question still stands - **what alternatives do we have for Windows 10 to achieve this functionality?** – qJake Oct 19 '17 at 20:39
  • [The last commin on their GitHub page is from 2016](https://github.com/aybe/Windows-API-Code-Pack-1.1/commits/master), is that library what you're talking about? – Alejandro Oct 19 '17 at 20:57
  • @Alejandro Yes that is the one I am using which is not working for my WPF .NET 4.5 project anymore. – qJake Oct 20 '17 at 14:31
  • Do you have some sample code that reproduces the problem? – Alejandro Oct 20 '17 at 20:23

1 Answers1

1

The Task Dialog is still supported in Windows 10, but the problem is likely this issue in the library that you seem to be using: https://github.com/aybe/Windows-API-Code-Pack-1.1/issues/3

As noted in the issue description, it can cause the AccessViolationException (and probably the incorrect characters) on 64-bit Windows. You can fix it by applying the changes from the referenced pull request.

Note: There is a request to include an official Task Dialog implementation in future .NET Core versions now that WinForms is open source: https://github.com/dotnet/winforms/issues/146