CallingConventions CallingConventions CallingConventions CallingConventions Enum

Definición

Define las convenciones de llamada válidas para un método.Defines the valid calling conventions for a method.

Esta enumeración tiene el atributo FlagsAttribute, que permite una combinación bit a bit de sus valores de miembro.

public enum class CallingConventions
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum CallingConventions
type CallingConventions = 
Public Enum CallingConventions
Herencia
CallingConventionsCallingConventionsCallingConventionsCallingConventions
Atributos

Campos

Any Any Any Any 3

Especifica que puede utilizarse la convención de llamada Standard o VarArgs.Specifies that either the Standard or the VarArgs calling convention may be used.

ExplicitThis ExplicitThis ExplicitThis ExplicitThis 64

Especifica que la firma es una firma de puntero de función, que representa una llamada a una instancia o un método virtual (no un método estático).Specifies that the signature is a function-pointer signature, representing a call to an instance or virtual method (not a static method). Si se establece ExplicitThis, también se debe especificar HasThis.If ExplicitThis is set, HasThis must also be set. El primer argumento pasado al método llamado sigue siendo un puntero this, pero el tipo del primer argumento ahora es desconocido.The first argument passed to the called method is still a this pointer, but the type of the first argument is now unknown. Por ello, se almacena en su firma de metadatos un token que describe el tipo (o clase) del puntero this.Therefore, a token that describes the type (or class) of the this pointer is explicitly stored into its metadata signature.

HasThis HasThis HasThis HasThis 32

Especifica una instancia o método virtual (no un método estático).Specifies an instance or virtual method (not a static method). En tiempo de ejecución, se pasa el método llamado como puntero al objeto de destino como primer argumento (el puntero this).At run-time, the called method is passed a pointer to the target object as its first argument (the this pointer). La firma almacenada en los metadatos no incluye el tipo de este primer argumento, ya que se conoce el método y puede detectarse su clase propietaria a partir de los metadatos.The signature stored in metadata does not include the type of this first argument, because the method is known and its owner class can be discovered from metadata.

Standard Standard Standard Standard 1

Especifica la convención de llamada predeterminada según lo establecido por Common Language Runtime.Specifies the default calling convention as determined by the common language runtime. Utilice esta convención de llamada para los métodos estáticos.Use this calling convention for static methods. Por ejemplo, los métodos virtuales utilizan HasThis.For instance or virtual methods use HasThis.

VarArgs VarArgs VarArgs VarArgs 2

Especifica la convención de llamada para los métodos con argumentos variables.Specifies the calling convention for methods with variable arguments.

Ejemplos

using namespace System;
using namespace System::Reflection;
using namespace System::Security;
public ref class MyClass1
{
public:
   MyClass1( int i ){}

};

int main()
{
   try
   {
      Type^ myType = MyClass1::typeid;
      array<Type^>^types = gcnew array<Type^>(1);
      types[ 0 ] = int::typeid;
      
      // Get the public instance constructor that takes an integer parameter.
      ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::Public), nullptr, CallingConventions::HasThis, types, nullptr );
      if ( constructorInfoObj != nullptr )
      {
         Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: " );
         Console::WriteLine( constructorInfoObj );
      }
      else
      {
         Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available." );
      }
   }
   catch ( ArgumentNullException^ e ) 
   {
      Console::WriteLine( "ArgumentNullException: {0}", e->Message );
   }
   catch ( ArgumentException^ e ) 
   {
      Console::WriteLine( "ArgumentException: {0}", e->Message );
   }
   catch ( SecurityException^ e ) 
   {
      Console::WriteLine( "SecurityException: {0}", e->Message );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
using System;
using System.Reflection;
using System.Security;

public class MyClass1
{
    public MyClass1(int i){}
    public static void Main()
    {
        try
        {
            Type  myType = typeof(MyClass1);
            Type[] types = new Type[1];
            types[0] = typeof(int);
            // Get the public instance constructor that takes an integer parameter.
            ConstructorInfo constructorInfoObj = myType.GetConstructor(
                BindingFlags.Instance | BindingFlags.Public, null,
                CallingConventions.HasThis, types, null);
            if(constructorInfoObj != null)
            {
                Console.WriteLine("The constructor of MyClass1 that is a public " +
                    "instance method and takes an integer as a parameter is: ");
                Console.WriteLine(constructorInfoObj.ToString());
            }
            else
            {
                Console.WriteLine("The constructor of MyClass1 that is a public instance " +
                    "method and takes an integer as a parameter is not available.");
            }
        }
        catch(ArgumentNullException e)
        {
            Console.WriteLine("ArgumentNullException: " + e.Message);
        }
        catch(ArgumentException e)
        {
            Console.WriteLine("ArgumentException: " + e.Message);
        }
        catch(SecurityException e)
        {
            Console.WriteLine("SecurityException: " + e.Message);
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
}
Public Class MyClass1
    Public Sub New(ByVal i As Integer)
    End Sub
    Public Shared Sub Main()
        Try
            Dim myType As Type = GetType(MyClass1)
            Dim types(0) As Type
            types(0) = GetType(Integer)
            ' Get the public instance constructor that takes an integer parameter.
            Dim constructorInfoObj As ConstructorInfo = _
                        myType.GetConstructor(BindingFlags.Instance Or _
                        BindingFlags.Public, Nothing, _
                        CallingConventions.HasThis, types, Nothing)
            If Not (constructorInfoObj Is Nothing) Then
                Console.WriteLine("The constructor of MyClass1 that " + _
                                  "is a public instance method and takes an " + _
                                  "integer as a parameter is: ")
                Console.WriteLine(constructorInfoObj.ToString())
            Else
                Console.WriteLine("The constructor MyClass1 that " + _
                                  "is a public instance method and takes an " + _
                                  "integer as a parameter is not available.")
            End If
        Catch e As ArgumentNullException
            Console.WriteLine("ArgumentNullException: " + e.Message)
        Catch e As ArgumentException
            Console.WriteLine("ArgumentException: " + e.Message)
        Catch e As SecurityException
            Console.WriteLine("SecurityException: " + e.Message)
        Catch e As Exception
            Console.WriteLine("Exception: " + e.Message)
        End Try
    End Sub
End Class

Comentarios

La convención de llamada nativa es el conjunto de reglas que rigen el orden y diseño de los argumentos pasados a métodos compilados.The native calling convention is the set of rules governing the order and layout of arguments passed to compiled methods. También controla cómo se pasa el valor devuelto, lo que registra que se usará para los argumentos y si la llamada o el método de llamada quita los argumentos de la pila.It also governs how to pass the return value, what registers to use for arguments, and whether the called or the calling method removes arguments from the stack.

Se aplica a