CallingConventions Enumeration

Definition

Definiert die gültigen Aufrufkonventionen für eine Methode.

Diese Enumeration unterstützt eine bitweise Kombination ihrer Memberwerte.

public enum class CallingConventions
[System.Flags]
public enum CallingConventions
[System.Flags]
[System.Serializable]
public enum CallingConventions
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConventions
[<System.Flags>]
type CallingConventions = 
[<System.Flags>]
[<System.Serializable>]
type CallingConventions = 
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CallingConventions = 
Public Enum CallingConventions
Vererbung
CallingConventions
Attribute

Felder

Any 3

Gibt an, dass entweder die Standard-Aufrufkonvention oder die VarArgs-Aufrufkonvention verwendet werden kann.

ExplicitThis 64

Gibt an, dass es sich bei der Signatur um eine Funktionszeiger-Signatur handelt, die einen Aufruf einer Instanz oder einer virtuellen Methode (keiner statischen Methode) darstellt. Wenn ExplicitThis festgelegt ist, muss HasThis ebenfalls festgelegt werden. Das erste an die aufgerufene Methode übergebene Argument ist weiterhin ein this-Zeiger, der Typ des ersten Arguments ist jedoch jetzt unbekannt. Deshalb wird ein Token, das den Typ (oder die Klasse) des this-Zeigers beschreibt, in der Signatur der Metadaten explizit gespeichert.

HasThis 32

Gibt eine Instanz oder eine virtuelle Methode (keine statische Methode) an. Zur Laufzeit wird der aufgerufenen Methode als erstes Argument ein Zeiger auf das Zielobjekt übergeben (der this-Zeiger). Die in den Metadaten gespeicherte Signatur enthält den Typ dieses ersten Arguments nicht, da die Methode bekannt ist und die Klasse, die diese besitzt, aus den Metadaten ermittelt werden kann.

Standard 1

Gibt die Standardaufrufkonvention an, die durch die Common Language Runtime bestimmt wurde. Verwenden Sie diese Aufrufkonvention für statische Methoden. Verwenden Sie HasThis für Instanzen oder virtuelle Methoden.

VarArgs 2

Gibt die Aufrufkonvention für Methoden mit variablen Argumenten an.

Beispiele

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

Hinweise

Die native Aufrufkonvention ist der Satz von Regeln für die Reihenfolge und das Layout von Argumenten, die an kompilierte Methoden übergeben werden. Außerdem wird erläutert, wie der Rückgabewert übergeben wird, welche Register für Argumente verwendet werden sollen, und ob die aufgerufene oder aufrufende Methode Argumente aus dem Stapel entfernt.

Gilt für