Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Type.GetTypeFromHandle Method

Gets the type referenced by the specified type handle.

[Visual Basic]
Public Shared Function GetTypeFromHandle( _
   ByVal handle As RuntimeTypeHandle _
) As Type
[C#]
public static Type GetTypeFromHandle(
 RuntimeTypeHandle handle
);
[C++]
public: static Type* GetTypeFromHandle(
 RuntimeTypeHandle handle
);
[JScript]
public static function GetTypeFromHandle(
   handle : RuntimeTypeHandle
) : Type;

Parameters

handle
The RuntimeTypeHandle object that refers to the type.

Return Value

The type referenced by the specified RuntimeTypeHandle.

Exceptions

Exception Type Condition
ArgumentNullException handle is a null reference (Nothing in Visual Basic).
TargetInvocationException A class initializer is invoked and throws an exception.

Remarks

The handles are valid only in the application domain in which they were obtained.

If the requested type is non-public and the caller does not have ReflectionPermission to reflect non-public objects outside the current assembly, this method returns a null reference (Nothing in Visual Basic).

Example

[Visual Basic] 
Dim myClass1 As New MyClass1()
' Get the type referenced by the specified type handle.
Dim myClass1Type As Type = Type.GetTypeFromHandle(Type.GetTypeHandle(MyClass1))
Console.WriteLine(("The Names of the Attributes :" + myClass1Type.Attributes.ToString()))
   End Sub 'Main 

[C#] 
MyClass1 myClass1 = new MyClass1();
 // Get the type referenced by the specified type handle.
Type myClass1Type = Type.GetTypeFromHandle(Type.GetTypeHandle(myClass1));
Console.WriteLine("The Names of the Attributes :"+myClass1Type.Attributes);

[C++] 
MyClass1* myClass1 = new MyClass1();
// Get the type referenced by the specified type handle.
Type*  myClass1Type = Type::GetTypeFromHandle(Type::GetTypeHandle(myClass1));
Console::WriteLine(S"The Names of the Attributes : {0}",__box( myClass1Type->Attributes));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

Type Class | Type Members | System Namespace | RuntimeTypeHandle | TypeHandle | GetTypeHandle | ReflectionPermission

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft