MahApps.Metro: The property IsWindows10OrHigher in BorderlessWindowBehavior throws exception

What steps will reproduce this issue?

The property IsWindows10OrHigher in MahApps.Metro/Behaviours/BorderlessWindowBehavior.cs introduced in https://github.com/MahApps/MahApps.Metro/commit/fe7dd828dbc945a705f10be67983a75a147328fc#diff-783a1e5d5018be41e08311212094178e is causing an exception on Windows 10 with Aniversary update. Seems that there are problems with WMI (even when running as administrator…)

Message: Access denied Stack Trace:

at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext() at System.Linq.Enumerable.<OfTypeIterator>d__921.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) at MahApps.Metro.Behaviours.BorderlessWindowBehavior.IsWindows10OrHigher() in C:\TeamCity\buildAgent\work\b90af7509433a217\MahApps.Metro\Behaviours\BorderlessWindowBehavior.cs:line 38 at MahApps.Metro.Behaviours.BorderlessWindowBehavior.OnAttached() in C:\TeamCity\buildAgent\work\b90af7509433a217\MahApps.Metro\Behaviours\BorderlessWindowBehavior.cs:line 47 at System.Windows.Interactivity.Behavior.Attach(DependencyObject dependencyObject) at System.Windows.Interactivity.BehaviorCollection.ItemAdded(Behavior item) at System.Windows.Interactivity.AttachableCollection1.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at System.Windows.FreezableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Windows.FreezableCollection1.OnCollectionChanged(NotifyCollectionChangedAction action, Int32 oldIndex, T oldValue, Int32 newIndex, T newValue) at System.Windows.FreezableCollection1.AddHelper(T value) at MahApps.Metro.Behaviours.StylizedBehaviors.OnPropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e) in C:\TeamCity\buildAgent\work\b90af7509433a217\MahApps.Metro\Behaviours\StylizedBehaviors.cs:line 68 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.StyleHelper.ApplyStyleOrTemplateValue(FrameworkObject fo, DependencyProperty dp) at System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList1& exclusionContainerDependents, FrugalStructList1& oldContainerDependents, FrugalStructList`1& newContainerDependents) at System.Windows.StyleHelper.DoThemeStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldThemeStyle, Style newThemeStyle, Style style) at System.Windows.StyleHelper.UpdateThemeStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldThemeStyle, Style newThemeStyle, Style& themeStyleCache) at System.Windows.FrameworkElement.OnThemeStyleChanged(DependencyObject d, Object oldValue, Object newValue) at System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce) at System.Windows.FrameworkElement.UpdateThemeStyleProperty() at System.Windows.FrameworkElement.OnInitialized(EventArgs e) at System.Windows.FrameworkElement.TryFireInitialized() at System.Windows.FrameworkElement.EndInit() at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)

Expected outcome

Not causing an exceptoin

Environment

  • MahApps.Metro v1.3.0-ALPHA199
  • Windows 10 with Aniversary update
  • Visual Studio 2015
  • .NET Framework 4.6.1

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@punker76 I noticed that too. I also checked the Version Helper functions, but to use them your application must be manifested. Therefore go for RtlGetVersion šŸ‘