473,382 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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",
oConn);
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("Select * FROM Win32Reg_AddRemovePrograms");
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);
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 2130

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Morris | last post by:
I'm new to .NET and just trying a few things out, like emailing. I created a form in Visual Studio .Net to input some information for generating an email and I'm getting the following error when it...
3
by: Alexander Farber | last post by:
Hi, does anyone have an idea, why do I get the following error (I have to use g++296 on RedHat Linux as compiler): In file included from r_dir.cpp:9: r_obey.h:262: declaration of `const...
7
by: | last post by:
I found similiar issues in MS-KB but nothing that helped me; got the Windows and Office updates from the MS website but that hasn't changed the behavior of this problem, and I don't see anything...
5
by: charliewest | last post by:
I've implemented the USING statement to ensure that my newly created sql connection closes when my method is finished using it. The USING statement is wrapped in try/catch error handling statement....
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
9
by: Kobe | last post by:
Is there any difference in: template <class T> vs. template <typename T> ?
11
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put...
7
by: Søren Dreijer | last post by:
Hi, I have a mixed C#, managed C++ and unmanaged C++ project. The managed class calls a method which exists in an unmanaged singleton class. During the entire lifetime of the application, this...
2
by: Kerem Gümrükcü | last post by:
Hi, i have a Process.Start call that fails with 267 Error Code if invoked with another user and password other than the applications user. It is a ordinary piece of code just create a Process...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.