This documentation is archived and is not being maintained.
CallingConventions Enumeration
Visual Studio 2010
Defines the valid calling conventions for a method.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Namespace: System.ReflectionAssembly: mscorlib (in mscorlib.dll)
| Member name | Description | |
|---|---|---|
![]() ![]() | Standard | Specifies the default calling convention as determined by the common language runtime. Use this calling convention for static methods. For instance or virtual methods use HasThis. |
![]() ![]() | VarArgs | Specifies the calling convention for methods with variable arguments. |
![]() ![]() | Any | Specifies that either the Standard or the VarArgs calling convention may be used. |
![]() ![]() | HasThis | Specifies an instance or virtual method (not a static method). At run-time, the called method is passed a pointer to the target object as its first argument (the this pointer). 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. |
![]() ![]() | ExplicitThis | Specifies that the signature is a function-pointer signature, representing a call to an instance or virtual method (not a static method). If ExplicitThis is set, HasThis must also be set. The first argument passed to the called method is still a this pointer, but the type of the first argument is now unknown. Therefore, a token that describes the type (or class) of the this pointer is explicitly stored into its metadata signature. |
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 ); } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:

