Mono Class Library: System.Type Overview | Members

System.Type.GetType Method

Returns the Type with the specified name, optionally throwing an exception if an error occurs while loading the Type .

public static Type GetType (string typeName, bool throwOnError)

Parameters

typeName
A string containing the case-sensitive name of the Type to return.
throwOnError
A bool. Specify true to throw a TypeLoadException if an error occurs while loading the Type. Specify false to ignore errors while loading the Type.

Returns

The Type with the specified name, if found; otherwise, null . If the requested type is non-public and the caller does not have permission to reflect non-public objects outside the current assembly, this method returns null .

Permissions

TypeReason
System.Security.Permissions.ReflectionPermissionRequires permission to retrieve information on non-public objects. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation

Exceptions

TypeReason
ArgumentNullExceptiontypeName is null.
System.Reflection.TargetInvocationExceptionA type initializer was invoked and threw an exception.
TypeLoadExceptionthrowOnError is true and an error was encountered while loading the Type.

Remarks

This method is equivalent to Type.GetType(string, bool, bool)(name, throwOnError, false).

typeName can be a simple type name, a fully qualified name, or a complex name that includes an assembly name specification. If typeName includes only the name of the Type, this method searches in the calling object's assembly, then in the mscorlib.dll assembly. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly.

Note: Type.AssemblyQualifiedName can return a fully qualified type name including nested types, the assembly name, and generic type arguments. For complete details, see Type.GetType(string, bool, bool)(string, bool, bool).

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0