Howard Hinman

I have been trying to get WMI working from C#. THe following console application receives an exception with the error message "Invalid Method Parameter(s)" when the methon on the final like tries to execute. Any have any suggestions

Also, I have not been able to find a working sample of a C# program setting an IP Address on a network adapter. Any links or pointers would be greatly appreciated. The following programs contains a reference to System.Management and System.Deployment. and no other references than the defualts for a console application. There are no other classes or programs in the application.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Net;

using System.Net.NetworkInformation;

using System.Globalization;

using System.ComponentModel.Design.Serialization;

using System.Reflection;

using System.Runtime.InteropServices;

using System.Management;

using System.Management.Instrumentation;

using System.IO;

using System.Text;

namespace WMI_Problem


class Program


static void Main(string[] args)


setDNSServerSearchOrder("[00000001] Broadcom NetXtreme 57xx Gigabit Controller");


static void setDNSServerSearchOrder(string nicName)


ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");

ManagementObjectCollection moc = objMC.GetInstances();

// Not sure if following two statements are needed - found in an example

// Same problem occurs if they are commented out

objMC.Scope.Options.EnablePrivileges = true;


foreach (ManagementObject mo in moc)


if ((bool)mo["IPEnabled"])


if (mo["Caption"].Equals(nicName))


string DNS = ",";

System.Management.ManagementBaseObject inParams =


inParams["DNSServerSearchOrder"] = DNS.Split(',');

//The follow Invokes causes an exception with the error message:

// "Invalid Method Parameter(s)"

ManagementBaseObject setDNS =

objMC.InvokeMethod("SetDNSServerSearchOrder", inParams, null);







Re: .NET Framework Networking and Communication WMI Error with C#

Dmitry Pavlov

Moved from Visual Studio Extensibility forum.