microsoft / microsoft/microsoft-ui-xaml

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'ObjectReference'.

Open
#9,963 4 comments 0 reactions 0 assignees View on GitHub
area-Lifetime bug team-Core team-Rendering
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

We're getting verified crashes from our logging system Sentry, but we're unable to replicate the issue. The app just dies, and we get a report with an exception message like this:

```
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'ObjectReference'.
?, in void IObjectReference.ThrowIfDisposed()
?, in T IObjectReference.AsType()
?, in int ExceptionHelpers.GetHRForException(Exception ex)
?, in int EventHandler.Do_Abi_Invoke(Void* thisPtr, IntPtr sender, TAbi args)
```

This happens pretty frequently, probably 1-2 times per user hour. We have "breadcrumbs" of what happened in the UI, but so far, that hasn't really shown us any correlation of specific steps to take to replicate the problem.

### Steps to reproduce the bug

See description, no indications of how to reproduce the problem.

### Expected behavior

**A better exception.** Details about what triggered this via a helpful stack trace. We have no idea what caused this crash and it's not anywhere in our code. We only need to know what's wrong so we can fix/avoid whatever we're doing now.

### Screenshots

None, it's happening to production users that haven't been able to capture the problem with screen recording (yet)

### NuGet package version

We're on 1.6.240923002

### Windows version

Windows 11 (22631)

Contributor guide

Open the contributing guide

Research direction

No source file, test, or entry point is identified. Start with the reported IObjectReference.ThrowIfDisposed, IObjectReference.AsType, ExceptionHelpers.GetHRForException, and EventHandler.Do_Abi_Invoke frames, then investigate the production crash data for a reproducible trigger. Done means identifying the cause or producing an actionable stack trace for the reported WinUI package version.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.