WMI a SNMP

G

Guest

HI all,
sorry for my bad eglisch . I have questation about SNMP . I want trap the
snmp traps . I am write this code :
ManagementScope ms = new ManagementScope("root/snmp/localhost");
ms.Connect();
WqlEventQuery wql = new WqlEventQuery("select * from SNMPNotification");
ManagementEventWatcher mew = new ManagementEventWatcher(ms,wql);
mew.EventArrived +=new EventArrivedEventHandler(mew_EventArrived);
after I call mew.Start() the trap work , but after few hour the trap not
work .
where is trouble ?
thanx
 
C

Carlos J. Quintero [.NET MVP]

Hi Marek,

Move the ManagementEventWatcher mew declaration outside the procedure, and
declare it at class level. Otherwise eventually is garbage-collected after
some time.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
G

Guest

I try :
public class snmp_tracer : System.ServiceProcess.ServiceBase
{
private System.Data.SqlClient.SqlConnection sqlcon;
private System.ComponentModel.Container components = null;
private System.Data.SqlClient.SqlCommand sqlcom;
public ManagementEventWatcher mew;
but still not work .....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top