Using C# System.Management to change adapter settings
I am developing a command line utility that will allow an end user to configure the network adapters via command line. This is a C# (.NET 2.0) application running on Window Embedded Standard 2009. I can enumerate the IANet_PhysicalEthernetAdapters and IANet_AdapterSettings just fine. However, I cannot figure out how to update a setting. I'm trying something like this, but keep getting a "Generic failure" exception.
_objSetting["CurrentValue"] = newVal;
NetService ns = NetService.GetInstance();
uint clientHandle, followupAction;
ManagementNamedValueCollection context = new ManagementNamedValueCollection();
The _objSetting.Put(..) is causing the exception "Generic failure".
I appear to be getting a valid client handle from the BeginApply() function call. After the crash, it takes a bit before I can even run this again, as I'm having to wait for that lock to timeout. Development and testing is on Vista, but I get the same error on XP64 test machine as well.
I have search the web cannot find any examples on how to change these settings using C# WMI classes. I'm obviously missing an important step.