tags:

views:

35

answers:

0

I am developing a window application in Microsoft visual C # 2008 express edition.I get a run time error wen i run the application.

        string[] diskArray;
        string driveNumber;
        string driveLetter;

        **searcher1 = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDiskToPartition");**
        foreach (ManagementObject dm in searcher1.Get()) {

            diskArray = null;
            driveLetter = getValueInQuotes(dm["Dependent"].ToString());
            diskArray = getValueInQuotes(dm["Antecedent"].ToString()).Split(',');
            driveNumber = diskArray[0].Remove(0, 6).Trim();
            if(driveLetter==this._driveLetter){
                /* This is where we get the drive serial */
                ManagementObjectSearcher disks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");

                foreach (ManagementObject disk in disks.Get()) {

                    if (disk["Name"].ToString() == ("\\\\.\\PHYSICALDRIVE" + driveNumber) & disk["InterfaceType"].ToString() == "USB") {
                        this._serialNumber = parseSerialFromDeviceID(disk["PNPDeviceID"].ToString());

(in the highlighted line) Context 0x3c74b38 is disconnected. No proxy will be used to service the request on the COM component. This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM components that live inside them.

thank u