Assembly.CreateInstance Method

Locates the specified type from this assembly and creates an instance of it using the system activator, using case-sensitive search.

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

public Object CreateInstance(
	string typeName
)

Parameters

typeName
Type: System.String
The Type.FullName of the type to locate.

Return Value

Type: System.Object
An instance of Object representing the type, with culture, arguments, binder, and activation attributes set to null, and BindingFlags set to Public or Instance, or null if typeName is not found.

ExceptionCondition
ArgumentException

typeName is an empty string ("") or a string beginning with a null character.

ArgumentNullException

typeName is null.

MissingMethodException

No matching constructor was found.

FileNotFoundException

typeName requires a dependent assembly that could not be found.

FileLoadException

typeName requires a dependent assembly that was found but could not be loaded.

BadImageFormatException

typeName requires a dependent assembly, but the file is not a valid assembly.

-or-

typeName requires a dependent assembly which was compiled for a version of the runtime later than the currently loaded version.

MemberAccessException

The method is invoked late-bound through mechanisms such as Type.InvokeMember.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: