Type.GetType Method (String, Func(AssemblyName, Assembly), Func(Assembly, String, Boolean, Type), Boolean)
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.
Assembly: mscorlib (in mscorlib.dll)
static member GetType : typeName:string * assemblyResolver:Func<AssemblyName, Assembly> * typeResolver:Func<Assembly, string, bool, Type> * throwOnError:bool -> Type
- Type: System.String
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 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.
- Type: System.Func(AssemblyName, Assembly)
A method that locates and returns the assembly that is specified in typeName. The assembly name is passed to assemblyResolver as an 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.
Caution Do not pass methods from unknown or untrusted callers. Doing so could result in elevation of privilege for malicious code. Use only methods that you provide or that you are familiar with.
- Type: System.Func(Assembly, String, Boolean, Type)
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.
Caution Do not pass methods from unknown or untrusted callers.
- Type: System.Boolean
true to throw an exception if the type cannot be found; false to return a null reference (Nothing in Visual Basic). Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
Return ValueType: System.Type
The type with the specified name. If the type is not found, the throwOnError parameter specifies whether a null reference (Nothing in Visual Basic) is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of throwOnError. See the Exceptions section.
typeName is a null reference (Nothing in Visual Basic).
A class initializer is invoked and throws an exception.
throwOnError is true and the type is not found.
throwOnError is true and typeName contains invalid characters, such as an embedded tab.
throwOnError is true and typeName is an empty string.
throwOnError is true and typeName represents an array type with an invalid size.
typeName represents an array of TypedReference.
An error occurs when typeName is parsed into a type name and an assembly name (for example, when the simple type name includes an unescaped special character).
throwOnError is true and typeName contains invalid syntax (for example, "MyType[,*,]").
typeName represents a generic type that has a pointer type, a ByRef type, or Void as one of its type arguments.
typeName represents a generic type that has an incorrect number of type arguments.
typeName represents a generic type, and one of its type arguments does not satisfy the constraints for the corresponding type parameter.
throwOnError is true and the assembly or one of its dependencies was not found.
typeName contains an invalid assembly name.
typeName is a valid assembly name without a type name.
The assembly or one of its dependencies was found, but could not be loaded.
The assembly or one of its dependencies is not valid.
The assembly was compiled with a later version of the common language runtime than the version that is currently loaded.
Usage scenarios for this method and details about the assemblyResolver and typeResolver parameters can be found in the GetType(String, Func(AssemblyName, Assembly), Func(Assembly, String, Boolean, Type), Boolean, Boolean) method overload.
Calling this method overload is the same as calling the GetType(String, Func(AssemblyName, Assembly), Func(Assembly, String, Boolean, Type), Boolean, Boolean) method overload and specifying false for the ignoreCase parameter.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.