IMethodMessage.HasVarArgs Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a value indicating whether the message has variable arguments.

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

bool HasVarArgs {

Property Value

Type: System.Boolean

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

Exception Condition

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));

       Console.WriteLine("\t The method have variable arguments!!");
       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;


for operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission value: SecurityPermissionFlag.Infrastructure

.NET Framework
Available since 1.1
Return to top