[英]Why new ManagementObject(@“root\WMI”, “BcdStore”, null) throws exception?
使用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.
怎么了?
您正在使用的ManagementObject构造函数的版本期望WMI路径作为参数,并且您仅传递类名,因此必须使用类似这样的东西。
var classInstance = ManagementObject(@"root\WMI", "BcdStore.FilePath=''", null);
注意:系统存储区用空字符串(“”)表示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.