Problems using the WMI EnableStatic method

Could it be that you are inputting IPv6 addresses as well? Just playing around with PowerShell it seems not to like them. Perhaps you can post actual values that are being inputted whilst debugging, it would help a lot. Also maybe try statically inputting some values like:

new string[]{"192.168.0.1"}, new string[] {"255.255.255.255"}

Also unless you really, really need C# and a GUI you may want to consider using PowerShell (requirement is it being installed of course) as WMI is really much simpler to manipulate there (sadly you still have that learning curve though).

This is just an example of how to use PowerShell, you can at the very least use it for some testing:

Get-WmiObject Win32_NetworkAdapterConfiguration

Then get the index of your adapter then run, but replace your index number:

$obj = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.Index -eq 1}
$obj.EnableStatic("192.168.0.1", "255.255.255.0")

To get method parameters just run:

$obj.EnableStatic

It will return:

MemberType          : Method
OverloadDefinitions : {System.Management.ManagementBaseObject EnableStatic(System.String[]IPAddress, System.String[] SubnetMask)}
TypeNameOfValue     : System.Management.Automation.PSMethod
Value               : System.Management.ManagementBaseObject EnableStatic(System.String[]IPAddress, System.String[] SubnetMask)
Name                : EnableStatic
IsInstance          : True

Tags:

C#

Wmi