I am testing an existing application in the Windows 8 consumer preview and it crashes upon launching. The log files indicate it is in the method where I do some validation on the CPU ID and Network card details.
To do this, I am calling
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo.Length == 0)
{
// only return cpuInfo from first CPU
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
}
(Note that this application works fine on Windows 7 and earlier).
I then use the same syntax for hooking into Win32_NetworkAdapterConfiguration and getting the IPEnabled, IPAddress[], and MACAddress properties.
But somewhere in here it is crashing.
I have tried to research this already, and found the following Windows 8 server list of WMI classes and methods and the ones I am using are not on it. However, the same site has a list of Windows 7 WMI classes and methods too, and these aren't in that either! (Even though it works on Windows 7 no problem).
So from the look of that, it is not supported.
The MSDN for the ManagementClass indicates that the method is still present in .NET 4.5. Additionally, this Microsoft resource does explicitly list Win32_Processor and Win32_NetworkAdapterConfiguration, with the methods I need.
So, from the links, you can see I have tried to research this, so this is my last stop in trying to solve this mystery.
My app is originally a .NET 2.0 solution created in Visual Studio 2005. I have installed Visual Studio 2011 Beta into my Windows 8 Consumer Preview VM, along with the latest SQL 2012 Express. I have tried importing my project into this Visual Studio but it doesn't load it, telling me that it only supports Metro development. Therefore I cannot debug this issue on the machine itself.
So my question is specifically do these classes exist in Windows 8? If they do, then what am I doing wrong? If they don't, then I need to find out a way to still get this information - but I guess that's a separate question ;-)
This has been answered but unfortunately only in comments on my original post, by Alex K. Using http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8572 I was able to identify these methods do exist, so I figure it's a coding issue as my code is slightly different to what is generated by that utility.