windows - RegistryTreeChangeEvent via C# & WMI -


"itemprop =" text ">

I am getting this error:

Exception without verb: System.Runtime.InteropServices.COMException (0x80042001): Exception from HRESULT: in MyNamespace.Program.Main on System.Management.ManagementEventWatcher.Start on System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal (Int32 errorCode, IntPtr errorInfo) () (String [] args) 0x80042001 { } Somedir \ Program.cs: line 16

And here is my C # console app that I am using to view the registry:

  Using the system ; Using System.Management; Namespace MyNamespace {class program {static void key (string [] args) {var viewer = new ManagementEventWatcher (New WqlEventQuery (select "RegistryTreeChangeEvent *")); Var Handler = New MyHandler (); Watcher.EventArrived + = Handler. Valid; // Start looking for Event Viewer. Start (); While (handler.eventshinstead) {// nothing} // stop watching the watch. Stop (); } Public class MyHandler {public bool EventHasntFiredYet; Public MyHandler () {EventHasntFiredYet = true; } Public Zero (object sender, EventArrivedEventArgs e) {var propertyDataCollection = e.NewEvent.Properties; Foreach (Property DataCollection var p) {Console.WriteLine ("{0} - {1}", P. Names, P. Valle); } EventHasntFiredYet = false; }}}  

}

I am just trying to see the registry for changes. Does anyone have a suggestion that this is unsuccessful?

"itemprop =" text ">

This is an internal WMI error, WBEMESS_E_REGISTRATION_TOO_BROAD," Provider registration system overlaps event domains. "

This is a good error message as you ever get out of COM, how bad the bitterness is. There are NET exception messages, I'm pretty sure that this means that "you are asking in a variety of ways" you have to be more selective in your query, use the WHERE section as:

< P> Select * RegistryTreeChangeEvent
Where Hive = 'HKEY_LOCAL_MACHINE' and 'RootPath =' SOFTWARE \ Microsoft \ '

From Giorgi, I found that the problem documents.

The following is an example of a wrong registration

Select * RegistryTreeChangeEvent from where hive = HKEY_LOCAL_MACHINE "or rootpath =" software "

Because each property There is no way to evaluate possible values, the WMI error rejects WBEM_E_TOO_BROAD from any query, which does not contain any WHERE clause or if the WHERE section is too broad for any use.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -