Note that there are some explanatory texts on larger screens.

plurals
  1. POC# WMI Query for Win32_PerfFormattedData_PerfOS_Memory returns 'Invalid class'
    text
    copied!<p>I'm running Windows 7 64Bit.</p> <p>This problem has only recently occurred as I have been working on the same section within the WMI several months ago without a problem.</p> <p>This is a machine specific problem as I have tried this test program on several other PCs and it works.</p> <p>I have run wbemtest, connected with authentication type packet and successfully enumerated the Win32_PerfFormattedData_PerfOS_Memory object and I can view the internals of the MOF which is what I am trying to do in my software.</p> <p>I have also removed and rebuilt the WMI Repository and tried re-syncing the PERF data.</p> <p>My C# application also connects with the authentication type of Packet.</p> <p>Here is the code for my simple test application (<a href="http://pastebin.com/nvNKCM2y" rel="nofollow">pastebin</a>): </p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Management; namespace WMITest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(Dump()); } string Dump() { string HOST = "WILLIAM-PC"; string Data = ""; try { ConnectionOptions CO = new ConnectionOptions(); CO.Authentication = AuthenticationLevel.Packet; ManagementScope Scope = new ManagementScope(@"\\" + HOST + @"\root\cimv2", CO); Scope.Connect(); if (! Scope.IsConnected) { MessageBox.Show("Not connected!"); } Scope.Options.EnablePrivileges = true; SelectQuery Query = new SelectQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Memory"); ManagementObjectSearcher MOS = new ManagementObjectSearcher(Scope, Query); foreach (ManagementObject MO in MOS.Get()) { foreach (PropertyData PD in MO.Properties) { Data = Data + PD.Name + " = " + PD.Value + "\n"; } } return Data; } catch (Exception E) { return "Exception: " +E.Message ; } } } } </code></pre> <p>Any suggestions would be gratefully received. Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload