为什么 new ManagementObject(@"root\WMI", "BcdStore", null) 会抛出异常?

2023-12-02

Using WMI Code Creator,我正在尝试拨打电话root\WMI\BcdStore.EnumerateObjects()。但是我在第一行代码中遇到异常:

var classInstance = new ManagementObject(
    @"root\WMI", "BcdStore", null); // <== exception!!!

// Obtain in-parameters for the method
var inParams = classInstance.GetMethodParameters("EnumerateObjects");

// ... 

例外的是:

A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Management.dll

Additional information: Specified argument was out of the range of valid values.

怎么了?


的版本管理对象您正在使用的构造函数需要 WMI 路径作为参数,并且您只传递类名,因此您必须使用类似的东西。

var classInstance = ManagementObject(@"root\WMI", "BcdStore.FilePath=''", null);

注意:系统存储由空字符串(“”)表示。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 new ManagementObject(@"root\WMI", "BcdStore", null) 会抛出异常? 的相关文章

随机推荐