Hi all,
I'm trying to write a custom decoupled WMI provider in C#. I've followed the examples and yet whenever I try to access my WMI class from either WMI Studio, through PowerShell, or via wmic, it just hangs there indefinitely until I terminate the provider host app, at which point I get an error ranging from "Invalid Class" to "The remote procedure call failed".
I can see my WMI provider fine if I don't try to actually access an instance of it, so I know it's registering with WMI.
Here's the code I'm running:
[assembly: WmiConfiguration(@"root\CIMV2", HostingModel=ManagementHostingModel.Decoupled)] [RunInstaller(true)] public class WmiInstaller : DefaultManagementInstaller { } [ManagementEntity(Singleton=true)] [ManagementQualifier("Description", Value="Accesses and manipulates licenses held in the SLN license database.")] public class SoftwareLicensingNetworkLicenseDatabase { [ManagementBind] public SoftwareLicensingNetworkLicenseDatabase() { Test = "OMG!"; } [ManagementProbe] public string Test; }
And then in my main function:
[STAThread] static void Main() { InstrumentationManager.RegisterType(typeof(SoftwareLicensingNetworkLicenseDatabase)); Console.ReadLine(); InstrumentationManager.UnregisterType(typeof(SoftwareLicensingNetworkLicenseDatabase)); }
I've tried any number of things to diagnose this issue: switch to .Net 3.5 (I'm using .Net 4.0), change namespace names, use a multi-instance class instead of a singleton, etc.
Any help would be sincerely appreciated!