InstrumentationManager Class
Provides methods that manage the lifetime and the model used for decoupled providers.
Assembly: System.Management.Instrumentation (in System.Management.Instrumentation.dll)
The InstrumentationManager type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | Publish | Makes an instance of a provider available within the WMI infrastructure. |
![]() ![]() | RegisterAssembly | Registers an assembly with the WMI infrastructure. |
![]() ![]() | RegisterType | Registers a class with the WMI infrastructure. |
![]() ![]() | Revoke | Takes an instance of a currently available provider and makes it unavailable within the WMI infrastructure. |
![]() ![]() | UnregisterAssembly | Unregisters an assembly currently registered with the WMI infrastructure. |
![]() ![]() | UnregisterType | Unregisters a class registered with the WMI infrastructure. |
Decoupled providers are hosted by an application. Two methods can be used by the application to make instances of WMI classes available: publish/revoke or the callback method. The callback method uses the RegisterType and UnregisterType methods.
In the publish/revoke model, the WMI infrastructure provides default behavior for many of the methods you have to write yourself in the callback method. These include the enumeration and bind methods. In this model, the application creates instances and publishes them. The application is responsible for ensuring that the key properties of the classes are respected. The application is also responsible for deleting instances.
In the callback model, the WMI infrastructure expects the application to have methods that handle enumeration, binding and any other methods required to implement the functionality of the provider. It calls into the application for this functionality and fails if it does not exist or is not implemented properly. The application registers the type of its WMI classes with the infrastructure by calling RegisterType and indicates that it no longer wants the WMI classes exposed by calling UnregisterType.
The following example demonstrates how to use the publish/revoke model. Two instances of the router class are created and published. They are later revoked.
public class Sample_InstanceProvider
{
public int Main (string[] args)
{
Router r_one = new Router ();
r_one.Name = "one";
InstrumentationManager.Publish(r_one);
Router r_two = new Router ();
r_two.Name = "two";
InstrumentationManager.Publish(r_two);
// ....
InstrumentationManager.Revoke(r_one);
InstrumentationManager.Revoke(r_two);
return 0;
}
}
In the next example, the callback method of registration is used to expose the RouterNew class.
public int MainNew(string[] args)
{
InstrumentationManager.RegisterType(typeof(RouterNew));
// ....
InstrumentationManager.UnRegisterType(typeof(RouterNew));
return 0;
}
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
