WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Failed to Create the Print Dialog via PrintManagerInterop

Open winnative opened this issue 4 months ago • 8 comments

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

  1. Create a Winui 3 Packaged app (C#).
  2. Make it Unpackaged.
  3. Create a function to show the dialog via PrinterManagerInterop method.
  4. You'll get the error.

Expected behavior

I want this function, show the print dialog, but i've just got this exception.

Screenshots

Image

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

winnative avatar Aug 20 '25 09:08 winnative

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...)

castorix avatar Aug 20 '25 12:08 castorix

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.

DarranRowe avatar Aug 20 '25 17:08 DarranRowe

@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 avatar Aug 25 '25 15:08 ssparach

@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)?

winnative avatar Aug 25 '25 16:08 winnative

@DarranRowe Honestly, I haven't tried this in a non WinUI 3 app yet!

winnative avatar Aug 25 '25 16:08 winnative

What is the HResult of the exception? Maybe you need to ensure the API is called on the UI thread?

whiskhub avatar Aug 25 '25 19:08 whiskhub

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.

DarranRowe avatar Sep 02 '25 17:09 DarranRowe