System.Type.GetType Method

Gets the type with the specified name, specifying whether to throw an exception if the type is not found, and optionally providing custom methods to resolve the assembly and the type.

Syntax

public static Type GetType (string typeName, Func<System.Reflection.AssemblyName, System.Reflection.Assembly> assemblyResolver, Func<System.Reflection.Assembly, string, bool, Type> typeResolver, bool throwOnError)

Parameters

typeName
The name of the type to get. If the typeResolver parameter is provided, the type name can be any string that typeResolver is capable of resolving. If the assemblyResolver parameter is provided or if standard type resolution is used, typeName must be an assembly-qualified name (see Type.AssemblyQualifiedName), unless the type is in the currently executing assembly or in Mscorlib.dll, in which case it is sufficient to supply the type name qualified by its namespace.
assemblyResolver
A method that locates and returns the assembly that is specified in typeName. The assembly name is passed to assemblyResolver as an System.Reflection.AssemblyName object. If typeName does not contain the name of an assembly, assemblyResolver is not called. If assemblyResolver is not supplied, standard assembly resolution is performed.
typeResolver
A method that locates and returns the type that is specified by typeName from the assembly that is returned by assemblyResolver or by standard assembly resolution. If no assembly is provided, the method can provide one. The method also takes a parameter that specifies whether to perform a case-insensitive search; false is passed to that parameter.
throwOnError
true to throw an exception if the type cannot be found; false to return null. Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.

Returns

The type with the specified name. If the type is not found, the throwOnError parameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of throwOnError. See the Exceptions section.

Remarks

Usage scenarios for this method and details about the assemblyResolver and typeResolver parameters can be found in the Type.GetType(string, Func<System.Reflection.AssemblyName, System.Reflection.Assembly>, Func<System.Reflection.Assembly, string, bool, System.Type>,System.Boolean,System.Boolean) method overload.

Calling this method overload is the same as calling the Type.GetType(string, Func<System.Reflection.AssemblyName, System.Reflection.Assembly>, Func<System.Reflection.Assembly, string, bool, System.Type>,System.Boolean,System.Boolean) method overload and specifying false for the ignoreCase parameter.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0