RESOLUTION
This behavior can occur in three different scenarios. The following are workarounds for each scenario.
Case 1
Scenario
You use code that is generated by using the Management Strongly Typed Generator (MgmtClassGen.exe) to generate a managed class for a WMI class.
Workaround
Manually add
null as the third parameter of
ManagementObject.InvokeMethod.
Case 2
Scenario
You use code that is generated by using Server Explorer to generate a managed class for a WMI class.
Workaround
Manually add
null as the third parameter of
ManagementObject.InvokeMethod.
Case 3
Scenario
You drag an instance of the class from Server Explorer to a Windows Form or to a Web Form Application.
Workaround
Manually add the
null parameter for
ManagementObject.InvodeMethod. Additionally, you must add a member variable for the class, and then add initialization code to the application to replace the code that would have been generated by the drag-and-drop process. Add the following sample code. (In these samples, the class generated is named
MyClass, and it is located in the ROOT\DEFAULT namespace.)
For a Windows Form Application, add the following sample code:
In Visual C# .NET
// Add a member variable to the application class.
private WindowsApplication1.ROOT.DEFAULT.MyClass MyClass1;
// Initalization code to be added to InitializeComponent:
this.MyClass1 = new WindowsApplication1.ROOT.DEFAULT.MyClass();
// Complete WMI path of the instance that you dragged:
this.MyClass1.Path =
new System.Management.ManagementPath("root\\DEFAULT:MyClass.Id=10");
In Visual Basic .NET
' Add a member variable to the application class.
Friend WithEvents MyClass1 As WindowsApplication1.ROOT.DEFAULT.MyClass
' Initialization Code to be added to InitializeComponent:
Me.MyClass1 = New WindowsApplication1.ROOT.DEFAULT.MyClass()
' Complete WMI path of the instance that you dragged:
Me.MyClass1.Path = _
New System.Management.ManagementPath("root\DEFAULT:MYClass.Id=10")