Calling a DNS WMI Provider method with no input parameters.


New member
Jul 7, 2004
Programming Experience
Im trying to invoke a method in the DNS WMI Provider.

If the method has input parameters, then everything works fine.

If the method doesnt have input parameters, then i get an exception: Invalid Methd Parameter(s)

Below is an example:

Const DNS_SERVER_NAME As String = "." 
	Const ERROR_SUCCESS As Integer = 0 
	Public Shared Function StartService() As Boolean 
		' Get the object on which the method will be invoked. 
		Dim processClass As New ManagementClass("\\" & DNS_SERVER_NAME & "\ROOT\MicrosoftDNS:MicrosoftDNS_Server") 
		'Invoke the method "StartService". 
		Dim outParams As ManagementBaseObject = processClass.InvokeMethod("StartService", Nothing, Nothing) 
		'Check for Error_Success and return. 
		If outParams("ReturnValue") = ERROR_SUCCESS Then 
			Return True 
			Return False 
		End If 
	End Function

This is the link that describes the StartService() method:

This method has NO input parameters. As you see above I send it Nothing but I still get the error message.

Does anyone know what I'm doing wrong?
Top Bottom