microsoft / microsoft/microsoft-ui-xaml

Obscure error message when modifying property accessed by UI on timer thread

Open
#9,984 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-CoreFramework bug team-Core team-Markup
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Normally, when you access anything that the UI concerns from another thread, you have to go through the dispatcher. A member in the UWP Community Discord ran into this same problem, but was met with a very undescriptive error message, saying `System.Runtime.InteropServices.COMException: ""`.

Though, I do recall seeing the proper error message before when this happened, but I don't remember how long ago that was.

### Steps to reproduce the bug

https://github.com/Pdawg-bytes/WASDK-INPC-COMException-repro/tree/main
Clone this repository and run the app. Take note of the comments in `App1/SystemViewModel.cs`.

### Expected behavior

When you attempt to access something like this, the error message should tell you that you need to use the Dispatcher to dispatch it to the UI thread.

### Screenshots

Here's the undescriptive error message:
![image](https://github.com/user-attachments/assets/a74a8c61-3449-4f19-ad06-bdbfb7fce861)

### NuGet package version

WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007

### Windows version

Windows 11 (22H2): Build 22621

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone and run the linked WASDK-INPC-COMException-repro app, starting with the comments in App1/SystemViewModel.cs. Reproduce the timer-thread property access and trace where the empty COMException is surfaced; done means the failure provides the expected guidance to dispatch access to the UI thread.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.