This documentation is archived and is not being maintained.

IMethodMessage.HasVarArgs Property

Gets a value indicating whether the message has variable arguments.

Namespace:  System.Runtime.Remoting.Messaging
Assembly:  mscorlib (in mscorlib.dll)

bool HasVarArgs { get; }

Property Value

Type: System.Boolean
true if the method can accept a variable number of arguments; otherwise, false.

ExceptionCondition
SecurityException

The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.

The following example code shows a custom proxy that overrides RealProxy.Invoke in order to write the message information to the console, including whether the method call has variable arguments.

// Overriding the Invoke method of RealProxy. 
public override IMessage Invoke(IMessage message)
{
   IMethodMessage myMethodMessage = (IMethodMessage)message;

   Console.WriteLine("**** Begin Invoke ****");
   Console.WriteLine("\tType is : " + myType);
   Console.WriteLine("\tMethod name : " +  myMethodMessage.MethodName);

   for (int i=0; i < myMethodMessage.ArgCount; i++)
   {
      Console.WriteLine("\tArgName is : " + myMethodMessage.GetArgName(i));
      Console.WriteLine("\tArgValue is: " + myMethodMessage.GetArg(i));
   }

   if(myMethodMessage.HasVarArgs)
       Console.WriteLine("\t The method have variable arguments!!");
   else
       Console.WriteLine("\t The method does not have variable arguments!!");

   // Dispatch the method call to the real object.
   Object returnValue = myType.InvokeMember( myMethodMessage.MethodName, BindingFlags.InvokeMethod, null,
                                        myObjectInstance, myMethodMessage.Args );
   Console.WriteLine("**** End Invoke ****");

   // Build the return message to pass back to the transparent proxy.
   ReturnMessage myReturnMessage = new ReturnMessage( returnValue, null, 0, null,
       (IMethodCallMessage)message );
   return myReturnMessage;
}
	// Overriding the Invoke method of RealProxy.
public:
	IMessage* Invoke(IMessage* message) 
	{
		IMethodMessage* myMethodMessage = dynamic_cast<IMethodMessage*>(message);

		Console::WriteLine(S"**** Begin Invoke ****");
		Console::WriteLine(S"\tType is : {0}", myType);
		Console::WriteLine(S"\tMethod name : {0}", myMethodMessage->MethodName);

		for (int i=0; i < myMethodMessage->ArgCount; i++) 
		{
			Console::WriteLine(S"\tArgName is : {0}", myMethodMessage->GetArgName(i));
			Console::WriteLine(S"\tArgValue is: {0}", myMethodMessage->GetArg(i));
		}

		if (myMethodMessage->HasVarArgs)
			Console::WriteLine(S"\t The method have variable arguments!!");
		else
			Console::WriteLine(S"\t The method does not have variable arguments!!");

		// Dispatch the method call to the real Object*.
		Object* returnValue = myType->InvokeMember(myMethodMessage->MethodName, BindingFlags::InvokeMethod, 0,
			myObjectInstance, myMethodMessage->Args);
		Console::WriteLine(S"**** End Invoke ****");

		// Build the return message to pass back to the transparent proxy.
		ReturnMessage* myReturnMessage = new ReturnMessage(returnValue, 0, 0, 0,
			dynamic_cast<IMethodCallMessage*>(message));
		return myReturnMessage;
	}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: