TaskDialog not working on (or replacement for) Windows 10?

烂漫一生 提交于 2021-01-27 20:20:28

问题


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?


回答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



来源:https://stackoverflow.com/questions/46838210/taskdialog-not-working-on-or-replacement-for-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!