Re: ManagementEventWatcher.Stop() fails to close connection to Win2003



mabra,

I have confirmed that the application is running on win2003 SP1 w/ .net 1.1 SP1. In this case at least SP1 is not helping.

'Win32_ProcessStartTrace' is not available on Win2000 (MSDN indicates it was not around until XP.) Are you aware of a better way to monitor processes on Win200 than with __InstanceCreationEvent? It doesn't matter in my case, since I am just watching to see if long-running processes fail.

Thanks for taking a look at this.

-- Colin

mabra wrote:
Hi !

I saw this error also sometimes. I do not understand all the possible reasons for this, but each time, I saw this, I verfified to have the .Net 1.1 SP1 installed. This solved the problems the most time for me.

Annotation:Watching processes without the "Win32_ProcessStartTrace" is not very solid.

> SELECT * FROM __InstanceCreationEvent WITHIN 60 WHERE TargetInstance ISA
> 'Win32_Process' AND TargetInstance.Name = 'notepad.exe'

means, that WMI takes a snapshot at the beginning and at of the end of the specified interval. If there is a hazard, starting at second 10 of your specified minute and it ends at second 30 of this minute, you'll never see him ;-)

May be, I could help.
Best regards,
Manfred

removethis wrote:
Hello,

I'm writing a .net 1.1 Windows Service app that monitors process creation & destruction on remote systems. I use the ManagementEventWatcher class to create asynchronous WQL event queries.

When the remote system is Win2000 I use this query:
SELECT * FROM __InstanceCreationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'notepad.exe'

I pass this query to a ManagementEventWatcher and call Start(). Everything works fine. Later I call Stop() and receive the Stopped event, as expected.

For Win2003 I use a different query:
SELECT * FROM Win32_ProcessStartTrace

This query avoids the WITHIN polling and also give me faster notification when a process is started. Start() works as expected and I receive EventArrived events.

The problem is that about an hour later when I call Stop() on the watcher I always receive this error:
System.Runtime.InteropServices.COMException (0x80010108): The object invoked has disconnected from its clients.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)
at System.Management.SinkForEventQuery.Cancel()
at System.Management.ManagementEventWatcher.Stop()
at WMIMonitor.WMIProcessWatcher.Stop() in c:\cygwin\home\...\wmimonitor\wmiconnection.cs:line 289

I ignored this error until I noticed that I continue to receive events these watchers that fail to stop. My service periodically stops and disposes all the watchers and creates new ones, so over the course of a day these lingering watchers add up. I receive duplicate events from the monitored server (one for the 'open' watcher and one each for each watcher that failed to stop.)

Obviously this is wasting resources on the remote server and is not acceptable.

With the exception of the query, I use the exact same code to connect to Win2000 and Win2003 servers. But .Stop() always fails on 2003. As far as I can tell everything is working fine on windows 2000.

My application is running on Win2003 SP1.

Any suggestions greatly appreciated.

Regards,
Colin
.



Relevant Pages

  • Re: ManagementEventWatcher.Stop() fails to close connection to Win2003
    ... I have confirmed that the application is running on win2003 SP1 w/ .net 1.1 SP1. ... I'm writing a .net 1.1 Windows Service app that monitors process creation & destruction on remote systems. ... I pass this query to a ManagementEventWatcher and call Start. ... The problem is that about an hour later when I call Stopon the watcher I always receive this error: ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Difference between SP1 And SP2
    ... it's a "Query not updateable" issue. ... Apparently it's a difference between SP1 and SP2 ... mentioned patent dispute). ...
    (microsoft.public.access.setupconfig)
  • Re: Performance problem on a XML data type column
    ... Queries with descendatn, ... I had written a post on my blog at the time SP1 was released and it contains ... If the schema is unregistered from the database, the query works perfectly. ...
    (microsoft.public.sqlserver.xml)
  • Two stupid questions!
    ... First, what is the best way to query for all clients with XP only, no ... When I create a query for XP SP1 and XP SP2 it works ... XP OEM clients in a collection. ... They don't report any ...
    (microsoft.public.sms.admin)

Loading