我尝试在MSDN中使用C#更新WMI实例,但是我无法让它工作。它解雇了我一个System.Management.ManagementException'这没有给我任何答案。如果我做错了,你能告诉我吗?
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);
}
答案 0 :(得分:0)
我将代码更改为此代码,现在可以正常运行:
AccessToken accessToken =
new DefaultFacebookClient().obtainExtendedAccessToken(MY_APP_ID,
MY_APP_SECRET, MY_ACCESS_TOKEN);