Access Violation and app crash when trying to debug Application.Current
See original GitHub issueDescribe the bug
I noticed that my app was crashing when trying to read the resources from a background thread:
var res = Application.Current?.Resources
I don’t actually want to start using things, but rather I wanted to get the dispatcher queue and then enqueue a delegate to update the dictionary. But, it appears just reading this crashes the app and also adding Application.Current in the IDE’s debug intermediate window also throws.
Steps to reproduce the bug
On a background thread:
var res = Application.Current?.Resources
Expected behavior
No crash and the resource dictionary is readable.
Screenshots
No response
NuGet package version
1.0.0
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 21H2 (22000)
IDE
Visual Studio 2022-preview
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Access Violation and app crash when trying to debug ...
Describe the bug I noticed that my app was crashing when trying to read the resources from a background thread: var res =...
Read more >c++ - How to diagnose Access Violation on application exit
I have an application that I'm trying to debug a crash in. However, it is difficult to detect the problem for a few...
Read more >Analyze Crashes to Find Security Vulnerabilities in Your ...
In response, we have developed simple heuristics to quickly analyze read-access violation crashes for code-execution potential.
Read more >Stackoverflow causes access violation in .net core
When I debug my .NET Core console application in VS 2017 (15.4.4) my application crashes and debugging stops.
Read more >App Crash: Access Violation
I am getting a crash trying to run a hololens app in the emulator. 'OnlineMaps211.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

In the meantime, the best practice is to store away a copy of the DispatcherQueue somewhere in an app global.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.