Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetTypeFromHandle Method

Type.GetTypeFromHandle Method

Gets the type referenced by the specified type handle.

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


The RuntimeTypeHandle object that refers to the type.

Return Value

The type referenced by the specified RuntimeTypeHandle.


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


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


[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 

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

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.


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

© 2015 Microsoft