WMI Com Interop exception handling

G

Guest

Hi all,

Using WMI I am attempting to catch and exception when doing a managementscope.connect operation.
From the looks of things, this method starts a new worker thread through Interop that then executes the method.
My problem is that regardless of what all I use in my catch statements, the system still raises the
initial dialog reporting the exception. Eventually, my app catches and handles the exception but
I cannot get the initial one. Is there a code snippet somewhere that shows how to hook into the
exception event handler in WMI or Interop? I am purposely running this against a machine that does
not have WMI enabled to ensure that an error will occur. I'm at a loss on how to handle this.
Heres a snip.... and hmmm.. sorry about the formatting....

Public Function blaa() as Boolean
Dim options As New ConnectionOptions()
Dim scope As ManagementScope
Dim blah As String
options.Username = "xxxx\Administrator"
options.Password = "****"
scope = New ManagementScope("\\" & "10.0.1.10" & "\root\cimv2", options)
Try
scope.Connect()
return true
Catch e As System.Management.ManagementException
Return False
Catch e As System.Runtime.InteropServices.COMException
Return False
Catch e As System.Exception
Return False
Catch e As Exception
Return False
End Try
End Function
 
G

Guest

Anyone have any idea's? I searched over in the Interop forum but havn't seen much. Is this something that I'll need to use reflection for possibly? I'm fairly new to this .Net so I'm not real clear on reflection usage. Btw, I've added handlers for current domain unhandled exceptions and for app threadexceptions and I still can't catch the error.
Thanks to anyone with any ideas ! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top