unhandled COMException, Catastrophic failure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code causes unhandled exception on the line:
New ManagementObjectSearcher(query)

Dim mos As System.Management.ManagementObjectSearcher
Dim moc As System.Management.ManagementObjectCollection
Dim mo As System.Management.ManagementObject
Dim query As String = "SELECT * FROM Win32_OperatingSystem"
mos = New System.Management.ManagementObjectSearcher(query)
moc = mos.Get()
For Each mo In moc
....

The whole error message:
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in system.management.dll
Additional information: Catastrophic failure

What is wrong?
 
Hi,

The following code works fine for me. A couple of things to keep in
mind. First wmi is not installed by default on windows 95, 98, and nt 4.0.
Second win32_operatingsystem only works with windows xp, 2000, 2003, and nt
4.

Link wmi redist package
http://www.microsoft.com/downloads/...BA-337B-4E92-8C18-A63847760EA5&displaylang=en

Code
' Add a Reference to System.Management

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_OperatingSystem")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strOut As String

strOut = String.Format("Name {0} - Serial Number {1}", mo("Name"),
mo("SerialNumber"))

Trace.WriteLine(strOut)

Next



Ken

-------------------------------

The following code causes unhandled exception on the line:
New ManagementObjectSearcher(query)

Dim mos As System.Management.ManagementObjectSearcher
Dim moc As System.Management.ManagementObjectCollection
Dim mo As System.Management.ManagementObject
Dim query As String = "SELECT * FROM Win32_OperatingSystem"
mos = New System.Management.ManagementObjectSearcher(query)
moc = mos.Get()
For Each mo In moc
....

The whole error message:
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in system.management.dll
Additional information: Catastrophic failure

What is wrong?
 
Thank you for your quick response.
I'm using WinXp Pro with SP1,
I deleted the System.Management reference and added it again, but your code
causes the same error for me, as mine. An interesting thing, that I can't
catch this exception with 'Catch E As Exception'.

M.
 
Hi,

Go to add remove programs in the control panel. Click on
add/remove windows components. Make sure management and monitoring tools is
checked that is the wmi.

Finally Catch e as exception will only catch non fatal errors. Use
to catch e as system.exception to catch all exceptions.

Ken
---------------------
Thank you for your quick response.
I'm using WinXp Pro with SP1,
I deleted the System.Management reference and added it again, but your code
causes the same error for me, as mine. An interesting thing, that I can't
catch this exception with 'Catch E As Exception'.

M.
 
You were right, the management and monitoring tools were not installed at my
PC, I installed it (in details WMI SNMP Provider also checked), made reboot
and tried again. Unfortunately the same error occured.
I tried catch it with 'Catch e As Ssystem.Exception', but it didn't help.

Do You know another way to get the same informations about the PC?
 
Hi,

Dim myReg As RegistryKey = Registry.LocalMachine

Dim MyRegKey As RegistryKey



MyRegKey = myReg.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion")

Trace.WriteLine(MyRegKey.GetValue("ProductID"))

Trace.WriteLine(MyRegKey.GetValue("RegisteredOwner"))

MyRegKey.Close()



Ken

---------------------------

You were right, the management and monitoring tools were not installed at my
PC, I installed it (in details WMI SNMP Provider also checked), made reboot
and tried again. Unfortunately the same error occured.
I tried catch it with 'Catch e As Ssystem.Exception', but it didn't help.

Do You know another way to get the same informations about the PC?
 

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

Back
Top