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.
1.1 --- a/WMI/WmiProvider.cs Thu Nov 04 21:46:14 2010 +0000
1.2 +++ b/WMI/WmiProvider.cs Thu Nov 11 20:48:19 2010 +0000
1.3 @@ -81,7 +81,9 @@
1.4 Hardware hw = new Hardware(hardware);
1.5 activeInstances.Add(hw);
1.6
1.7 - Instrumentation.Publish(hw);
1.8 + try {
1.9 + Instrumentation.Publish(hw);
1.10 + } catch (Exception) { }
1.11 }
1.12
1.13 foreach (IHardware subHardware in hardware.SubHardware)
1.14 @@ -92,7 +94,9 @@
1.15 Sensor sensor = new Sensor(data);
1.16 activeInstances.Add(sensor);
1.17
1.18 - Instrumentation.Publish(sensor);
1.19 + try {
1.20 + Instrumentation.Publish(sensor);
1.21 + } catch (Exception) { }
1.22 }
1.23
1.24 private void ComputerHardwareRemoved(IHardware hardware) {
1.25 @@ -125,7 +129,9 @@
1.26 item => item.Identifier == identifier.ToString()
1.27 );
1.28
1.29 - Instrumentation.Revoke(activeInstances[instanceIndex]);
1.30 + try {
1.31 + Instrumentation.Revoke(activeInstances[instanceIndex]);
1.32 + } catch (Exception) { }
1.33
1.34 activeInstances.RemoveAt(instanceIndex);
1.35 }
1.36 @@ -133,8 +139,11 @@
1.37 #endregion
1.38
1.39 public void Dispose() {
1.40 - foreach (IWmiObject instance in activeInstances)
1.41 - Instrumentation.Revoke(instance);
1.42 + foreach (IWmiObject instance in activeInstances) {
1.43 + try {
1.44 + Instrumentation.Revoke(instance);
1.45 + } catch (Exception) { }
1.46 + }
1.47 activeInstances = null;
1.48 }
1.49 }