Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in WindowsSettingBehavior #4013

Closed
Nuklon opened this issue Dec 26, 2020 · 1 comment · Fixed by #4058
Closed

NullReferenceException in WindowsSettingBehavior #4013

Nuklon opened this issue Dec 26, 2020 · 1 comment · Fixed by #4058
Assignees
Labels
Milestone

Comments

@Nuklon
Copy link
Contributor

Nuklon commented Dec 26, 2020

Describe the bug

System.NullReferenceException
at MahApps.Metro.Behaviors.WindowsSettingBehavior.<CleanUp>b__7_0() at offset 17
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, System.Object args, System.Int32 numArgs) at offset 55
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object source, System.Delegate callback, System.Object args, System.Int32 numArgs, System.Delegate catchHandler) at offset 2

Steps to reproduce

This sometimes happens on app shutdown. Looking at the code, I suspect Application.Current is null in BeginInvoke:

Application.Current?.BeginInvoke(() => Application.Current.SessionEnding -= this.CurrentApplicationSessionEnding);

Environment

MahApps.Metro version: v2.4.3
Windows build number: Win10 2004
Visual Studio: 2019 16.8.0
Target Framework: .Net v4.7.2
@Nuklon Nuklon added the Bug label Dec 26, 2020
@punker76 punker76 added this to the 2.4.4 milestone Dec 26, 2020
@punker76 punker76 self-assigned this Dec 26, 2020
@RafalNiewinski
Copy link

It also affects me with env:

MahApps.Metro version: v2.4.3.5
Target Framework: .NET 5.0

punker76 added a commit that referenced this issue Feb 28, 2021
Fix NullReferenceException in WindowsSettingBehavior
batzen pushed a commit to batzen/MahApps.Metro that referenced this issue Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants