0
我想在MSDN中使用C#更新一個WMI實例,下面的例子但我無法讓它工作。它解僱了我一個'System.Management.ManagementException',它不給我任何答案。你能告訴我如果我做錯了什麼嗎?WMI實例更新失敗
public void UpdateInstance(string parametersJSON)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
object result = serializer.Deserialize(parametersJSON, typeof(object));
Dictionary<string, object> dic = (Dictionary<string, object>)result;
PutOptions options = new PutOptions();
options.Type = PutType.UpdateOnly;
ManagementObject objHostSetting = new ManagementObject();
objHostSetting.Scope = new ManagementScope("root\\onguard");
objHostSetting.Path = new ManagementPath("Lnl_Cardholder.SSNO = '33263085'"); // This is the line that fires the exception
foreach (KeyValuePair<string, object> value in dic)
{
objHostSetting[value.Key] = value.Value.ToString();
}
//update the ManagementObject
objHostSetting.Put(options);
}