Thanks for clearing that up. Here's the core code:
ManagementScope scope = new ManagementScope();
ConnectionOptions connection = new ConnectionOptions();
ManagementObjectSearcher searcher = new ManagementObjectSearcher();
scope = new ManagementScope("\\\\TheComputer\\root\\CIMV2", connection);
scope.Connect();
searcher.Scope = scope;
searcher.Query = new ObjectQuery("select * from Win32_Product");
ManagementObjectCollection mc = searcher.Get();
foreach(ManagementObject mo in mc) // this throws the exception
{
// read contents of mo
}
The specific wmi query there should be irrelevant as it happens for that
query and all the others I'm trying to run.
-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of David L. Penton
Sent: Thursday, September 28, 2006 10:14 PM
To: [email protected]
Subject: Re: [ADVANCED-DOTNET] OS specific WMI error with .Net 1.1
He means that the new error is that you didn't include any code in your
post. Please reply with a sample of code that reproduces
the error.
&_david++;
******************************************************************
******************************************************************
******************************************************************
I'm trying to iterate over a ManagementObjectCollection with a foreach.
When running against a Windows 2000 Advanced Server with .Net 1.1 installed
I'm getting the following error:
COM object that has been separated from its underlying RCW can not be used.
The ManagementException.ErrorCode is -2146233087.
This does not happen when running against Windows Server 2003.
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com