Calling a DNS WMI Provider method with no input parameters.

natedoggsc

New member
Joined
Jul 7, 2004
Messages
1
Programming Experience
Beginner
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:

VB.NET:
Const DNS_SERVER_NAME As String = "." 
	Const ERROR_SUCCESS As Integer = 0 
 
	'StartService() 
	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 
		Else 
			Return False 
		End If 
	End Function

This is the link that describes the StartService() method:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/microsoftdns_server_startservice.asp

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