Skip to content

NullReferenceException in WindowsSettingBehavior #4013

@Nuklon

Description

@Nuklon

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions