Monitorian: Startup error : System.InvalidCastException
Hello,
I update Windows 10 to 11. I installed Windows 11 from scratch. The application worked fine in Windows 10 with my screens. But now I have an error :
[Date: 14/10/2021 23:06:25 Ver: 3.6.5.0]
System.InvalidCastException: Le cast spécifié n'est pas valide. HResult: -2147467262
à System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
à System.Management.SecuredIWbemServicesHandler.ExecQuery_(String strQueryLanguage, String strQuery, Int32 lFlags, IWbemContext pCtx, IEnumWbemClassObject& ppEnum)
à System.Management.ManagementObjectSearcher.Get()
à ScreenFrame.Helper.OsVersion.GetOsVersion()
à ScreenFrame.Helper.OsVersion.IsEqualToOrGreaterThan(Int32 major, Int32 minor, Int32 build, String propertyName)
à ScreenFrame.VisualTreeHelperAddition.GetDpi(Visual visual)
à ScreenFrame.Movers.StickWindowMover.TryGetAdjacentLocationToTaskbar(Double windowWidth, Double windowHeight, Rect& location)
à ScreenFrame.Movers.StickWindowMover.TryGetAdjacentLocation(Double windowWidth, Double windowHeight, Rect& location)
à ScreenFrame.Movers.BasicWindowMover.HandleWindowPosChanging(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
à ScreenFrame.Movers.WindowMover.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
à System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
I have the last version of NET Framework.
You have an idea ?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 31 (17 by maintainers)
Thanks for the report. Before going into details, your code will never return correct version because it always go through
throw new InvalidOperationException("Failed to get OS version.");
Comment that line out.