Gets the Type with the specified name, specifying whether to perform a case-sensitive search and whether to throw an exception if the type is not found. The type is loaded for reflection only, not for execution.
Assembly: mscorlib (in mscorlib.dll)
public static Type ReflectionOnlyGetType( string typeName, bool throwIfNotFound, bool ignoreCase )
- Type: System.Boolean
true to throw a TypeLoadException if the type cannot be found; false to return null if the type cannot be found. Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
- Type: System.Boolean
true to perform a case-insensitive search for typeName; false to perform a case-sensitive search for typeName.
Return ValueType: System.Type
The type with the specified name, if found; otherwise, null. If the type is not found, the throwIfNotFound parameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of throwIfNotFound. See the Exceptions section.
typeName is null.
A class initializer is invoked and throws an exception.
throwIfNotFound is true and the type is not found.
throwIfNotFound is true and typeName contains invalid characters, such as an embedded tab.
throwIfNotFound is true and typeName is an empty string.
throwIfNotFound is true and typeName represents an array type with an invalid size.
typeName represents an array of TypedReference objects.
typeName does not include the assembly name.
throwIfNotFound 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.
throwIfNotFound is true and the assembly or one of its dependencies was not found.
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.
If the assembly containing the type is not already loaded into the reflection-only context, using the method is equivalent to first loading the assembly for reflection only, using the ReflectionOnlyLoad method, and then loading the type by calling the assembly's Assembly.GetType method. For information about assembly-qualified names, see the Type.AssemblyQualifiedName property. For additional details on specifying type names, see the GetType(String, Boolean, Boolean) method overload.
If the assembly is already loaded for execution, another copy is loaded into the reflection-only context.
The throwIfNotFound parameter specifies what happens when the type is not found, and also suppresses certain other exception conditions, as described in the Exceptions section. Some exceptions are thrown regardless of the value of throwIfNotFound. For example, if the assembly is not valid, a BadImageFormatException is thrown even if throwIfNotFound is false.
For more information about using the reflection-only context, see How to: Load Assemblies into the Reflection-Only Context.
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.