I have a client that is getting the following error...
ception (0x80010002): Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))
The error is caused by the WMI not starting up before the program that is crashing. I plan to add a 10 sleep and try again if the error is HRESULT: 0x80010002 (RPC_E_CALL_CANCELED)...
BUT, I can't reproduce the error, so I don't know if the code If my error handling will work (or if I coded it correctly). My since the errorCode is a 32-bit Integer, I'm not sure if I can just convert 80010002 to an int (= 2147549186) and not have to pad it. Please let me know if the attached code snippet is correctly trapping 0x80010002
Private Function Identifier(ByVal wmiClass As String, ByVal wmiProperty As String) As String
'Return a hardware identifier
Dim Result As String = ""
Dim mc As New System.Management.ManagementClass(wmiClass)
Dim moc As System.Management.ManagementObjectCollection = mc.GetInstances
Dim mo As System.Management.ManagementObject
For Each mo In moc
'Only get the first one
If Result = "" Then
Result = mo(wmiProperty).ToString
Catch ex As Exception
Catch ex As Runtime.InteropServices.COMException
If ex.ErrorCode = 2147549186 Then '0x80010002
Return Identifier(wmiClass, wmiProperty)