469,645 Members | 1,702 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Trying To Query Remote Machine Using WMI & ASP.NET Fails With "Invalid Class"

I am trying to read a list of install programs using WMI with ASP.NET/C#.
However, it fails with "Invalid Class".

I have confirmed that if I query LOCALHOST then it works fine, but if I
query a remote machine then it fails. If I enter incorrect credentials,
then it fails with an access denied, so I know that I am at least connecting
to the WMI provider.

Here is the error:

Invalid class
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Management.ManagementException: Invalid class

Source Error:
Line 503: foreach(ManagementObject oReturn in oReturnCollection )

Source File: c:\program files\asp.net starter kits\asp.net portal
(csvs)\portalcsvs\desktopmodules\testconfiguration s.ascx.cs Line: 503
Here is what my code looks like:

ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = AdminUserName;
oConn.Password = AdminPass;
System.Management.ManagementScope oMs = new
System.Management.ManagementScope("\\\\" + Servername + "\\root\\cimv2",
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("Select * FROM Win32Reg_AddRemovePrograms");
ManagementObjectSearcher oSearcher = new
ManagementObjectCollection oReturnCollection = oSearcher.Get();

foreach(ManagementObject oReturn in oReturnCollection )
// Do something, but I don't even get into the foreach, it dies trying
to access the first object

Nov 18 '05 #1
0 1876

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Kobe | last post: by
11 posts views Thread by Kimmo Laine | last post: by
7 posts views Thread by Søren Dreijer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.