Assembly.GetType Method (String, Boolean)
Gets the Type object with the specified name in the assembly instance and optionally throws an exception if the type is not found.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.String
The full name of the type.
- Type: System.Boolean
true to throw an exception if the type is not found; false to return null.
Return ValueType: System.Type
An object that represents the specified class.
name is invalid.
The length of name exceeds 1024 characters.
name is null.
throwOnError is true, and the type cannot be found.
name requires a dependent assembly that could not be found.
name requires a dependent assembly that was found but could not be loaded.
The current assembly was loaded into the reflection-only context, and name requires a dependent assembly that was not preloaded.
name requires a dependent assembly, but the file is not a valid assembly.
name requires a dependent assembly which was compiled for a version of the runtime later than the currently loaded version.
This method only searches the current assembly instance. The name parameter includes the namespace but not the assembly. To search other assemblies for a type, use the Type.GetType(String) method overload, which can optionally include an assembly display name as part of the type name.
If the type has been forwarded to another assembly, it is still returned by this method. For information on type forwarding, see Type Forwarding in the Common Language Runtime.
The throwOnError parameter only affects what happens when the type is not found. It does not affect any other exceptions that might be thrown. In particular, if the type is found but cannot be loaded, TypeLoadException can be thrown even if throwOnError is false.
.NET FrameworkSupported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
XNA FrameworkSupported in: 3.0, 2.0, 1.0
Portable Class LibrarySupported in: Portable Class Library
Supported in: Windows Phone 8.1
Supported in: Windows Phone Silverlight 8.1
Supported in: Windows Phone Silverlight 8