views:

171

answers:

0

Hi !

I am working on a management helper application in C#, which deals with long running wmi-connections and these breaks with the following error:

Unhandled Exception: System.Runtime.InteropServices.COMException (0x80010108): The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED)

There is not really any helpful information on this and how connections work. As many times with WMI, I am dealing with a problem and the docs drives me mad :-(

There is nearly only the following sentence in the docs, which describes the connect/disconnect behavior [see:ManagementScope.IsConnected]:

"the scope is disconnected from the previous connection whenever the identifying properties of the scope are changed" ....

My code is usually working as long as my wmi-requests are made with short timeintervals. Imagine the folloing code [C#]:

ConnectionOptions co; //setting credentials and timeout
ManagementScope ms; //specifying remote machine
ManagementObjectCollection moc;

ms.Connect();

//moc = ...SelectQuery(ms, "select * from Win32_LogicalDisk"); //OK

while(true)
{
    Thread.Sleep(900000); //App doing other work;short=ok, long=BOMB
    if(!ms.IsConnected) //Never FALSE!!!
    {
        Console.WriteLine("Scope was NOT connected");
        ms.Connect(); //Never called,
        //but if done always, don't help!!
    }
    //[BOMB]Here is where the problem occurs:
    moc = ...SelectQuery(ms, "select * from Win32_LogicalDisk");
}

Regard:There is no .Dispose() currently and so the objects should still be alive and - regard the "docs", the "identifying properties of the scope" were never changed!!!

Any help would be really great, I am currently really out of hope now.

br--mabra