Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

No WMI-Instance shown for own decoupled WMI-provider

54 views
Skip to first unread message

ManfredR

unread,
Feb 25, 2010, 11:42:07 AM2/25/10
to
Full subject:
No WMI-Instance shown for subclass of root\cimv2\CIM_TemperatureSensor on
own decoupled WMI-Provider (using WMI.Net Provider Extension v2)

Hi all,

I tried to add an own temperature-sensor as Instance of a subclass of
root\cimv2\CIM_TemperatureSensor by using
WMI.net Provider Extension v2 with C# and VS2008 and provide it as DECOUPLED
WMI-Provider.

I implemented
root\cimv2\CIM_TemperatureSensor\MR_Subclass_CIM_TemperatureSensor class

Registration with Install-Util of .net Framework64\v2.0.50727 works fine.
The class is seen in WMI CIM-Studio but I could not generate an Instance so
that it is shown in CIM-Studio.
The code of my WMI-provider is added below, but fist some more information:

If I use the same code without a superclass, means directly in root\cimv2
(without the abstract ... class definition of the superclass)
the code works fine.

I tried InstrumentationManager.Publish() and
InstrumentationManager.RegisterType(), but my enumerator-methode was never
called
when I retrieve instances in CIM-Studio or with wmic.

A last very interesting aspect is (but I have no explanation for it):

My HardwareVendor provides already a Subclass to CIM_TemperatureSensor,
called FSCSV_TemperatureSensor.
If I derive my TemperatureSensor class below FSCSV_TemperatureSensor it
works, and I can see the Instance in CIM-Studio.
There is another problem, that I see the instance only if I directly
access the subclass. If I retrieve all instances of
the superclass "FSCSV_TemperatureSensor" only the instances from the
HardwareVendor are shown.
The only lines I changed therefore are
[ManagementEntity(External = true)]
abstract public class FSCSV_TemperatureSensor

and
[ManagementEntity(Name =
"MR_Subclass_FSCSV_TemperatureSensor")]
public class MR_Subclass_FSCSV_TemperatureSensor :
FSCSV_TemperatureSensor

Here now my code as subclass of the CIM_TemperatureSensor with this code:
What's wrong there?

I started my provider as a Win-Form with
mySubclassOfCIM_TemperatureSensor = new
MR_Subclass_CIM_TemperatureSensor("MRKeyvalueFrombuttonClick");
InstrumentationManager.Publish(mySubclassOfCIM_TemperatureSensor);

[assembly: WmiConfiguration(@"root\cimv2", HostingModel =
ManagementHostingModel.Decoupled, IdentifyLevel = false)]
[System.ComponentModel.RunInstaller(true)]
public class MyInstaller : DefaultManagementInstaller { }

namespace InstanceBelowCIM2
[ManagementEntity(External = true)]
abstract public class CIM_TemperatureSensor
{
protected string strTag; // is key property in DMTF and WMI
protected string strOtherIdentifyingInfo; // my Info there

[ManagementKey()]
public string DeviceID
{
get
{ return this.strTag; }
}
[ManagementProbe]
public string Caption
{
get
{ return this.strOtherIdentifyingInfo; }
}

}

[ManagementEntity(Name = "MR_Subclass_CIM_TemperatureSensor")]
public class MR_Subclass_CIM_TemperatureSensor :
CIM_TemperatureSensor
{

public MR_Subclass_CIM_TemperatureSensor(string Tag)
{
this.strTag = "MR_subclassKeyvalue";
this.strOtherIdentifyingInfo = "addInfo constructor called";
}

[ManagementBind]

static public MR_Subclass_CIM_TemperatureSensor
myGetInstance_nur_fuer_bind(string deviceID) //only for installutil
{
MR_Subclass_CIM_TemperatureSensor myowninstance = new
MR_Subclass_CIM_TemperatureSensor("EnumInstance");
myowninstance.strOtherIdentifyingInfo = "This is Toms PC";
return myowninstance;
}

// WMI expect an enumeration interface
[ManagementEnumerator]
static public IEnumerable EnumerateInstances(string tag)
//(string Tag, string creationclassname)
{
for (int i = 0; i < 1; i++)
{
MR_Subclass_CIM_TemperatureSensor myowninstance = new
MR_Subclass_CIM_TemperatureSensor("EnumInstance");
myowninstance.strOtherIdentifyingInfo = "This is Toms PC";
yield return myowninstance;
}
}
}

Thanks in advance


0 new messages