传递的实例名称未被 WMI 数据提供程序识别为有效

The instance name passed was not recognized as valid by a WMI data provider

我正在尝试通过 "logman.exe" 创建一个性能计数器并尝试读取 Microsoft Tx (LINQ to Logs and Traces),但我遇到了以下错误,

System.ComponentModel.Win32Exception: 'The instance name passed was not recognized as valid by a WMI data provider'

Process logman = Process.Start(
            "logman.exe",
            "create counter Test_Perf_log -c \"Processor(_Total)\"% Processor Time");
        logman.WaitForExit();

        IObservable<EtwNativeEvent> session = EtwObservable.FromSession("Test_Perf_log");
        using (session.Subscribe(e => Console.WriteLine("{0} {1}", e.TimeStamp, e.UserData)))
        {
            Console.ReadLine();
        }

我怀疑通过 "logman.exe" 创建的计数器 "Test_Perf_log" 不正确,请帮助解决这个问题。

谢谢,

您的文本不正确:这是输出-

create counter Test_Perf_log -c "Processor(_Total)"% Processor Time

logman /?显示的格式是这样的:

create counter perf_log -c "\Processor(_Total)\% Processor Time"

为此,您可以使用:

"create counter perf_log -c \"\Processor(_Total)\% Processor Time\""