Found the following interesting discussion in the Newsgroups:
| WMI Com Interop exception handling by:Anonymous | |
| 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 | |
| Reply: by:Anonymous | |
| 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 ! :) | |
| Reply: by:Anonymous | |
| Anyone have any ideas on this? I've looked over in the interop forum but havn't seen anything jump out at me. I wonder if this is something that I need to use reflection for perhaps? I'm new to this .Net stuff so I'm not realy clear on how that works. BTW, I've added handlers for the current domain and the app thread exceptions and I still can't catch the initial error. Thanks to anyone with any ideas ! :) | |
Posted by Xander Zelders

0 Comments:
Post a Comment
<< Home