Skip to content

NullReferenceException in WindowsSettingBehaviorΒ #4013

Closed

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

Activity

  1. added this to the 2.4.4 milestone on Dec 26, 2020
  2. self-assigned this
    on Dec 26, 2020
  3. RafalNiewinski commented on Jan 6, 2021

    @RafalNiewinski

    It also affects me with env:

    MahApps.Metro version: v2.4.3.5
    Target Framework: .NET 5.0
    
  4. added a commit that references this issue on Feb 28, 2021
  5. added a commit that references this issue on Feb 28, 2021
  6. added a commit that references this issue on Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions