This documentation is archived and is not being maintained.

Activator.CreateInstance Method (Type)

.NET Framework 1.1

Creates an instance of the specified type using the constructor that best matches the specified parameter.

[Visual Basic]
Overloads Public Shared Function CreateInstance( _
   ByVal type As Type _
) As Object
public static object CreateInstance(
 Type type
public: static Object* CreateInstance(
 Type* type
public static function CreateInstance(
   type : Type
) : Object;


The type of object to create.

Return Value

A reference to the newly created object.


Exception Type Condition
ArgumentNullException type is a null reference (Nothing in Visual Basic).
ArgumentException type is not a RuntimeType.
NotSupportedException type cannot be a TypeBuilder.


Creation of TypedReference, ArgIterator, and RuntimeArgumentHandle types is not supported.

TargetInvocationException The constructor being called throws an exception.
MethodAccessException The caller does not have permission to call this constructor.
MemberAccessException Cannot create an instance of an abstract class or this member was invoked with a late-binding mechanism.
InvalidComObjectException COM type was not obtained through GetTypeFromProgID or GetTypeFromCLSID.
MissingMethodException No matching public constructor was found.
COMException type is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
TypeLoadException type is not a valid type.


The constructor to be invoked must be accessible.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

.NET Framework Security: 

  • SecurityPermission for the ability to call unmanaged code when creating an instance of a delegate. Associated enumeration: SecurityPermissionFlag/UnmanagedCode
  • ReflectionPermission for the ability to invoke operations on all type members. Associated enumeration: ReflectionPermissionFlag/MemberAccess

See Also

Activator Class | Activator Members | System Namespace | Activator.CreateInstance Overload List