emoacht / Monitorian

A Windows desktop tool to adjust the brightness of multiple monitors with ease
https://www.microsoft.com/store/apps/9nw33j738bl0
MIT License
3.16k stars 154 forks source link

Crash on start: Could not find Windows Runtime type 'Windows.Devices.Sensors.LightSensor' #513

Closed RadarNyan closed 10 months ago

RadarNyan commented 10 months ago

Full exception log:

[Date: 2023/09/14 19:53:35 Ver: 4.4.13.0]
System.TypeLoadException: Could not find Windows Runtime type 'Windows.Devices.Sensors.LightSensor'. HResult: -2146233054 TypeName: Windows.Devices.Sensors.LightSensor
 ---> System.PlatformNotSupportedException: Operation is not supported on this platform. HResult: -2146233031
   --- End of inner exception stack trace ---
   at Monitorian.Core.Models.Monitor.LightSensor.<>c.<.cctor>b__26_0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at Monitorian.Core.Models.Monitor.PowerManagement.get_CanAdaptiveBrightnessEnabled()
   at Monitorian.Core.Models.Monitor.PowerManagement.GetOnPowerSettingChanged()
   at Monitorian.Core.Models.Watcher.PowerWatcher.Subscribe(Action`1 onPowerChanged)
   at Monitorian.Core.AppControllerCore.<InitiateAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Monitorian.App.<OnStartup>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
   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)

[Date: 2023/09/14 19:53:39 Ver: 4.4.13.0]
System.TypeLoadException: Could not find Windows Runtime type 'Windows.Devices.Sensors.LightSensor'. HResult: -2146233054 TypeName: Windows.Devices.Sensors.LightSensor
 ---> System.PlatformNotSupportedException: Operation is not supported on this platform. HResult: -2146233031
   --- End of inner exception stack trace ---
   at Monitorian.Core.Models.Monitor.LightSensor.<>c.<.cctor>b__26_0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at Monitorian.Core.Models.Monitor.PowerManagement.get_CanAdaptiveBrightnessEnabled()
   at Monitorian.Core.Models.Monitor.PowerManagement.GetOnPowerSettingChanged()
   at Monitorian.Core.Models.Watcher.PowerWatcher.Subscribe(Action`1 onPowerChanged)
   at Monitorian.Core.AppControllerCore.<InitiateAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Monitorian.App.<OnStartup>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
   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)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   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)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at Monitorian.App.Main()

I'm on Windows 7 with an old AOC monitor.

If I just ignore the error message box:

---------------------------
Monitorian
---------------------------
An unexpected problem occurred. Save exception log to Desktop?
---------------------------
Yes   No   
---------------------------

Then I can control the brightness of this monitor from tray icon with no problem. If I click on the buttons, the message box would show a second time and after that the application crashes.

emoacht commented 10 months ago

Thank you for reporting. Should be fixed by 1e676e0fbe23511dd927cf68e2eaed5853a3c35e

RadarNyan commented 10 months ago

Confirm fixed with Ver 4.4.14, thanks for the quick fix.