From d9dc0f5b45d9e3eb8217600228e9a791c8a3523d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Thu, 11 Nov 2010 20:48:19 +0000 Subject: [PATCH] Added code to catch the "System.Exception: This schema for this assembly has not been registered with WMI." when the user has now administrator rights. --- WMI/WmiProvider.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/WMI/WmiProvider.cs b/WMI/WmiProvider.cs index 1080029..3f5c5c5 100644 --- a/WMI/WmiProvider.cs +++ b/WMI/WmiProvider.cs @@ -81,7 +81,9 @@ namespace OpenHardwareMonitor.WMI { Hardware hw = new Hardware(hardware); activeInstances.Add(hw); - Instrumentation.Publish(hw); + try { + Instrumentation.Publish(hw); + } catch (Exception) { } } foreach (IHardware subHardware in hardware.SubHardware) @@ -92,7 +94,9 @@ namespace OpenHardwareMonitor.WMI { Sensor sensor = new Sensor(data); activeInstances.Add(sensor); - Instrumentation.Publish(sensor); + try { + Instrumentation.Publish(sensor); + } catch (Exception) { } } private void ComputerHardwareRemoved(IHardware hardware) { @@ -125,7 +129,9 @@ namespace OpenHardwareMonitor.WMI { item => item.Identifier == identifier.ToString() ); - Instrumentation.Revoke(activeInstances[instanceIndex]); + try { + Instrumentation.Revoke(activeInstances[instanceIndex]); + } catch (Exception) { } activeInstances.RemoveAt(instanceIndex); } @@ -133,8 +139,11 @@ namespace OpenHardwareMonitor.WMI { #endregion public void Dispose() { - foreach (IWmiObject instance in activeInstances) - Instrumentation.Revoke(instance); + foreach (IWmiObject instance in activeInstances) { + try { + Instrumentation.Revoke(instance); + } catch (Exception) { } + } activeInstances = null; } }