question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Access Violation and app crash when trying to debug Application.Current

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MikeHillbergcommented, May 2, 2022

In the meantime, the best practice is to store away a copy of the DispatcherQueue somewhere in an app global.

0reactions
github-actions[bot]commented, Jul 28, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found