472,334 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 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 2042

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...
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...
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...
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...
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here:...
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...
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....
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.