# HG changeset patch # User moel.mich # Date 1289508499 0 # Node ID 631ab73d1ae125bcc08bd2b8677ecdec21f33bf8 # Parent 91800d0f54de4340dd527996bcd4ec22211dc1a5 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. diff -r 91800d0f54de -r 631ab73d1ae1 WMI/WmiProvider.cs --- a/WMI/WmiProvider.cs Thu Nov 04 21:46:14 2010 +0000 +++ b/WMI/WmiProvider.cs Thu Nov 11 20:48:19 2010 +0000 @@ -81,7 +81,9 @@ 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 @@ 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 @@ item => item.Identifier == identifier.ToString() ); - Instrumentation.Revoke(activeInstances[instanceIndex]); + try { + Instrumentation.Revoke(activeInstances[instanceIndex]); + } catch (Exception) { } activeInstances.RemoveAt(instanceIndex); } @@ -133,8 +139,11 @@ #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; } }