Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Type.ReflectionOnlyGetType Method

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.

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

public static Type ReflectionOnlyGetType (
	string typeName,
	bool throwIfNotFound,
	bool ignoreCase
)
public static Type ReflectionOnlyGetType (
	String typeName, 
	boolean throwIfNotFound, 
	boolean ignoreCase
)
public static function ReflectionOnlyGetType (
	typeName : String, 
	throwIfNotFound : boolean, 
	ignoreCase : boolean
) : Type
Not applicable.

Parameters

typeName

The name of the Type to get.

throwIfNotFound

true to throw a TypeLoadException if the type cannot be found; false to return a null reference (Nothing in Visual Basic) if the type cannot be found.

ignoreCase

true to perform a case-insensitive search for typeName; false to perform a case-sensitive search for typeName.

Return Value

The Type with the specified name, if found; otherwise, a null reference (Nothing in Visual Basic).
Exception typeCondition

ArgumentNullException

typeName is a null reference (Nothing in Visual Basic).

TargetInvocationException

A class initializer is invoked and throws an exception.

TypeLoadException

throwIfNotFound is true and the type is not found.

ArgumentException

typeName is invalid, for example if it contains invalid characters, or if it is a zero-length string.

If the assembly containing the type is not already loaded into the reflection-only context, and the type is assembly-qualified, using the ReflectionOnlyGetType 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 System.Reflection.Assembly.GetType method. For 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 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 throwIfNotFound is false.

For more information about using the reflection-only context, see How to: Load Assemblies into the Reflection-Only Context.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.