Simple WMI provider crashing.

A

Andrew

Hi,

I implemented a simple WMI Provider in C#.
It is a service which expose 10 instances of a simple WMI Class.
The WMI class pnly expose 4 public properties (Value,Min,Max,StdValue) which
only
return some constant data.

First, I was using MOM 2005 (Windows 2003) to interogate the instances
values.
The problem is that after a time (like 1 or 2 days max) I find the service
crashed. The
interogation is done each 15 seconds.

Then, I wrote a simple reader in C++ which read the instances values (the
reader and service provider are on the same machine with Windows XP). The
behaviour is the
same: the service is crushing after a while.

I do know about some WMI memory leaks but it does not seem this case.
The problems which other users seem to have is when they actually query a
provider values.

It seems like there are some problems with creating a simple provider too.

Again, the test provider is very simple. Here;s the code:

// excerpt from TestWMIService.cs
public class Service1 : System.ServiceProcess.ServiceBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private WMIParameter param1, param2, param3, param4, param5, param6,
param7, param8, param9, param10;

public Service1()
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();

param1 = new WMIParameter("inst1");
Instrumentation.Publish(param1);

param2 = new WMIParameter("inst2");
Instrumentation.Publish(param2);

param3 = new WMIParameter("inst3");
Instrumentation.Publish(param3);

param4 = new WMIParameter("inst4");
Instrumentation.Publish(param4);

param5 = new WMIParameter("inst5");
Instrumentation.Publish(param5);

param6 = new WMIParameter("inst6");
Instrumentation.Publish(param6);

param7 = new WMIParameter("inst7");
Instrumentation.Publish(param7);

param8 = new WMIParameter("inst8");
Instrumentation.Publish(param8);

param9 = new WMIParameter("inst9");
Instrumentation.Publish(param9);

param10 = new WMIParameter("inst10");
Instrumentation.Publish(param10);
}

.....

// WMIParameter.cs
using System;
using System.Management.Instrumentation;

namespace TestWMIService
{
[InstrumentationClass(InstrumentationType.Instance)]
public class WMIParameter
{
public WMIParameter(string instName)
{
instanceName = instName;
}

public string InstanceName
{
get
{
return instanceName;
}
}

public double StdDev
{
get
{
return 0.12345;
}
}

public double Min
{
get
{
return -123.45;
}
}

public double Max
{
get
{
return 123.45;
}
}

public double Value
{
get
{
return 123.45;
}
}

private string instanceName;
}
}


The system i tested:
..NET Framework 1.1 with SP1.
Windows XP SP2
Windows 2003 SP1.

I try to use adplus in -crash mode and I got a memory dump with 0x80000003
code. Seems like a heap access violation !?

Any ideas ?
Will replacing the C# provider with a C++ provider solve the problem ?

Thank you.
 

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