Failed to Create the Print Dialog via PrintManagerInterop
Describe the bug
When i was just trying to Show Dialog. (Just to show dialog, not initialize the preview elements). This error happened.
Steps to reproduce the bug
- Create a Winui 3 Packaged app (C#).
- Make it Unpackaged.
- Create a function to show the dialog via PrinterManagerInterop method.
- You'll get the error.
Expected behavior
I want this function, show the print dialog, but i've just got this exception.
Screenshots
NuGet package version
Windows App SDK 1.7.3: 1.7.250606001
Packaging type
Unpackaged
Windows version
Windows 11 version 24H2 (26100, June 2025 Update)
IDE
Visual Studio 2022
Additional context
No response
I re-tested on my OS (Windows 10 22H2) and I got exception twice ramdomly, and since, I could not get it again (I tried dozens of times...)
Do you have the same issue with this when using it in a non WinUI 3 application, such as C++, WPF or WinForms?
The PrintManager runtime class is in the Windows.Graphics.Printing namespace, so this would be part of Windows itself. The place to report Windows issues is actually the Feedback Hub. So if this happens in application types other than WinUI 3, then you should report it there.
@winnative Thanks for reporting this! Just to double-check—can you confirm that you're seeing this on Windows 11 version 24H2 (build 26100, June 2025 Update)? Appreciate your help!
@ssparach Thank you for reminding me. I checked it again and It's version 24H2 (build 26100, February 2025 Update). Has this issue been fixed in the new Windows Update (June 2025)?
@DarranRowe Honestly, I haven't tried this in a non WinUI 3 app yet!
What is the HResult of the exception? Maybe you need to ensure the API is called on the UI thread?
What is the HResult of the exception? Maybe you need to ensure the API is called on the UI thread?
That shouldn't be as critical for desktop applications.
A lot of the UI thread restrictions for the UWP come about due to CoreWindow, but for desktop applications, the definition of a UI thread is pretty loose. Essentially, a UI thread is a thread that is able to receive messages. What's more, while the initial thread in a process is already a UI thread, any other thread in a desktop application can be converted in a few different ways. First, just outright calling CreateWindowEx (directly or indirectly) should convert the thread. Second, calling message functions such as GetMessage/PeekMessage will convert the thread. Third, calling IsGUIThread with TRUE in the convert parameter will convert the thread.