-
-
Notifications
You must be signed in to change notification settings - Fork 109
Open
Description
Describe the bug
This is a strange issue: if I subscribe to the ThemeManager.Current.SystemThemeChanged event, toggling "Hidden items" in File Explorer causes an exception to occur.
Timestamp: 2025/12/8 10:01:08
OSVersion: Microsoft Windows NT 10.0.26200.0
ClrVersion: 10.0.0
ThreadName: N/A(2)
----------------------------------------
Handler: DispatcherUnhandledException
----------------------------------------
Type: System.Reflection.TargetInvocationException
Source: System.Private.CoreLib
Message: Exception has been thrown by the target of an invocation.
TargetSite: System.Object InvokeWithFewArgs(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
StackTrace:
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.InvokeCallback(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
HResult: -2146232828
HelpLink: null
--- Inner Exception (Level 1) ---
Type: System.NullReferenceException
Source: HandyControl
Message: Object reference not set to an instance of an object.
TargetSite: Void <SystemEvents_UserPreferenceChanged>b__32_0()
StackTrace:
at HandyControl.Themes.ThemeManager.<SystemEvents_UserPreferenceChanged>b__32_0()
at HandyControl.Tools.DispatcherHelper.RunOnUIThread(DispatcherObject d, Action action)
at HandyControl.Tools.DispatcherHelper.RunOnMainThread(Action action)
at HandyControl.Themes.ThemeManager.SystemEvents_UserPreferenceChanged(Object sender, UserPreferenceChangedEventArgs e)
at InvokeStub_UserPreferenceChangedEventHandler.Invoke(Object, Span`1)
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
HResult: -2147467261
HelpLink: null
InnerException: null
Steps to reproduce the bug
- Subscribe
ThemeManager.Current.SystemThemeChanged += (_, _)=> { // NOP. }; - Open File Explorer, and toggle "Hidden items"
- Throw TargetInvocationException (NullReferenceException)
Expected behavior
No response
Screenshots
No response
NuGet package version
HandyControl 3.6.0
IDE
Visual Studio 2026
Framework type
.Net 10.0
Windows version
Windows 11 (25H2) - 26200.6584
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels