microsoft / microsoft/microsoft-ui-xaml

App crashes when clearing ObservableCollection

Open
#10,341 0 comments 1 reaction 0 assignees View on GitHub
area-ErrorHandling bug team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Clearing an `ObservableCollection` can cause this exception in certain cases (perhaps when page is unloaded and garbage collected):

`System.Runtime.InteropServices.COMException: Unspecified error`

### Steps to reproduce the bug

Download and run this example project: [Test.zip](https://github.com/user-attachments/files/18752216/Test.zip)

### Expected behavior

No crash

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

Related bug reports:
https://github.com/microsoft/microsoft-ui-xaml/issues/8684
https://github.com/microsoft/microsoft-ui-xaml/issues/7639
https://github.com/CommunityToolkit/Windows/issues/616

Contributor guide

Open the contributing guide

Research direction

Start by downloading and running the attached Test.zip on Windows 11 with Windows App SDK 1.6.3, then inspect the clearing and page-unload scenario that produces the COMException. Compare the behavior with related issues 8684, 7639, and 616; done means clearing the ObservableCollection no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.