Management Issues

S

scorpion53061

I get the following error with the class below it when installing on a
NT/98/Me machine. Any suggestions would be helpful. Kind of in a bind.
Suspect the issue revolves


System.Runtime.InteropServices.COMException (0x80040154): COM object with
CLSID {4590F811-1D3A-11D0-891F-00AA004B2E24} is either not valid or not
registered.
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObjectSearcher.Initialize()
at System.Management.ManagementObjectSearcher.Get()
at Computer_Information.clsWMI..ctor()
at Computer_Information.Form1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


System.Runtime.InteropServices.COMException (0x80040154): COM object with
CLSID {4590F811-1D3A-11D0-891F-00AA004B2E24} is either not valid or not
registered.
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObjectSearcher.Initialize()
at System.Management.ManagementObjectSearcher.Get()
at Computer_Information.clsWMI..ctor()
at Computer_Information.Form1.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Imports System.Management

Public Class clsWMI
Private objOS As ManagementObjectSearcher
Private objCS As ManagementObjectSearcher
Private objMgmt As ManagementObject
Private m_strComputerName As String
Private m_strManufacturer As String
Private m_StrModel As String
Private m_strOSName As String
Private m_strOSVersion As String
Private m_strSystemType As String
Private m_strTPM As String
Private m_strWindowsDir As String


Public Sub New()

objOS = New ManagementObjectSearcher("SELECT * FROM
Win32_OperatingSystem")
objCS = New ManagementObjectSearcher("SELECT * FROM
Win32_ComputerSystem")
For Each objMgmt In objOS.Get


m_strOSName = objMgmt("name").ToString()
m_strOSVersion = objMgmt("version").ToString()
m_strComputerName = objMgmt("csname").ToString()
m_strWindowsDir = objMgmt("windowsdirectory").ToString()
Next

For Each objMgmt In objCS.Get
m_strManufacturer = objMgmt("manufacturer").ToString()
m_StrModel = objMgmt("model").ToString()
m_strSystemType = objMgmt("systemtype").ToString
m_strTPM = objMgmt("totalphysicalmemory").ToString()
Next
End Sub

Public ReadOnly Property ComputerName()
Get
ComputerName = m_strComputerName
End Get

End Property
Public ReadOnly Property Manufacturer()
Get
Manufacturer = m_strManufacturer
End Get

End Property
Public ReadOnly Property Model()
Get
Model = m_StrModel
End Get

End Property
Public ReadOnly Property OsName()
Get
OsName = m_strOSName
End Get

End Property

Public ReadOnly Property OSVersion()
Get
OSVersion = m_strOSVersion
End Get

End Property
Public ReadOnly Property SystemType()
Get
SystemType = m_strSystemType
End Get

End Property
Public ReadOnly Property TotalPhysicalMemory()
Get
TotalPhysicalMemory = m_strTPM
End Get

End Property

Public ReadOnly Property WindowsDirectory()
Get
WindowsDirectory = m_strWindowsDir
End Get

End Property

End Class
 
S

scorpion53061

Make sure WMI is not installed on Win NT4, 95, or 98.

HI Ken,

this was good and I thank you.

After installing this the exception is thrown that this class is not set to
an instance of an object. DO you have any ideas on why this might be? Is
there anythng you need to see to make that determination?
 
K

Ken Tucker [MVP]

Hi,

Try something like this. Maybe you can find the error.
Public Sub New()

Try

objOS = New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")

For Each objMgmt In objOS.Get



m_strOSName = objMgmt("name").ToString()

m_strOSVersion = objMgmt("version").ToString()

m_strComputerName = objMgmt("csname").ToString()

m_strWindowsDir = objMgmt("windowsdirectory").ToString()

Next

Catch

MessageBox.Show("Error with Win32_OperatingSystem")

End Try

Try

objCS = New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")

For Each objMgmt In objCS.Get

m_strManufacturer = objMgmt("manufacturer").ToString()

m_StrModel = objMgmt("model").ToString()

m_strSystemType = objMgmt("systemtype").ToString

m_strTPM = objMgmt("totalphysicalmemory").ToString()

Next

Catch

MessageBox.Show("Error with Win32_ComputerSystem")

End Try

End Sub


Ken
----------------
 
H

Herfried K. Wagner [MVP]

* "scorpion53061 said:
I get the following error with the class below it when installing on a
NT/98/Me machine. Any suggestions would be helpful. Kind of in a bind.
Suspect the issue revolves

In addition to the other replies: Notice that there is a separate group
available for .NET + WMI:
 
S

scorpion53061

Try something like this. Maybe you can find the error.

Everything is fine on 2000 and XP. It is only on 98 and Me that are drawing
the issues.

No more information is given than this on 98 and Me.

Any more thoughts?
Thank you for yoru help.
 
S

scorpion53061

Try something like this. Maybe you can find the error.

Hi Ken,

Using your suggestion I found where it is choking on WIN98 and WIN Me. Also
using that registry key I specified early returned as empty on the WIN ME
machine I tried it on.
 
M

mike

If you are using any 3rd party controls, make sure they are flagged as
vsdrfCOMSelfReg on your deployment. This is found as the Register
property of each file being installed.
 

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