FIX: WinMgmt Halts If You Get a WMI Object from One Namespace and Put it in Another Namespace (231226)



The information in this article applies to:

  • Microsoft Windows Management Instrumentation 1.1

This article was previously published under Q231226

SYMPTOMS

In WMI version 1.1, if you get an object from one namespace by using GetObject and put the object into a different namespace by using PutObject, Windows Management will halt.

RESOLUTION

If you are using WMI 1.5, this problem will not occur. If you are using WMI 1.1, upgrade to 1.5; otherwise, you must spawn a new instance of the class in the second namespace, and manually copy the property values from the object retrieved from the first namespace.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem has been fixed in WMI version 1.5.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Compile the following mof. This mof creates two namespaces, "namespace1" and "namespace2". Namespace2 is a child of namespace1. Both classes have an identical class named "test". An instance of test is created in namespace1:
    #pragma namespace("\\\\.\\ROOT")
    
    instance of __namespace
    {
    	name = "namespace1";
    };
    
    #pragma namespace("\\\\.\\ROOT\\namespace1")
    
    class test
    {
    	[key] string mykey;
    };
    
    instance of test
    {
    	mykey = "a";
    };
    
    instance of __namespace
    {
    	name = "namespace2";
    };
    
    #pragma namespace("\\\\.\\ROOT\\namespace1\\namespace2")
    
    class test
    {
    	[key] string mykey;
    
    };
  2. Run the following code in a C++ WMI client program. Error checking has been omitted for brevity:
    BSTR pNamespace1 = SysAllocString(L"root\\namespace1");
    BSTR pNamespace2 = SysAllocString(L"namespace2");
    IWbemServices *pIWbemServices1 = NULL;
    IWbemServices *pIWbemServices2 = NULL;
    IWbemLocator *pIWbemLocator = NULL;
    
    CoCreateInstance(CLSID_WbemLocator,NULL,CLSCTX_INPROC_SERVER,IID_IWbemLocator,(LPVOID *) &pIWbemLocator);
    
    // Connect to the first namespace
    pIWbemLocator->ConnectServer(pNamespace1,NULL,NULL,0L,0L,NULL,NULL,&pIWbemServices1);
    // Connect to the second namespace
    pIWbemServices1->OpenNamespace(pNamespace2,0,0,&pIWbemServices2,0);
    
    // Retrieve the object from the first namespace
    IWbemClassObject *pObject = NULL;
    BSTR pObjectName = SysAllocString(L"test.mykey=\"a\"");
    pIWbemServices1->GetObject(pObjectName,0L,NULL,&pObject,NULL);
    <BR/>
    // Put the object into the second namespace. This will cause WMI 1.1 WinMgmt to crash
    pIWbemServices2->PutInstance(pObject,0,0,0);
    						

Modification Type:MajorLast Reviewed:10/16/2002
Keywords:kbBug kbDSupport KB231226 kbAudDeveloper