Activator.CreateInstance Method (Type)
Creates an instance of the specified type using that type's default constructor.
Assembly: mscorlib (in mscorlib.dll)
type is a null reference (Nothing in Visual Basic).
type is not a RuntimeType.
type is an open generic type (that is, the ContainsGenericParameters property returns true).
type cannot be a TypeBuilder.
The assembly that contains type is a dynamic assembly that was created with AssemblyBuilderAccess.Save.
The constructor being called throws an exception.
The caller does not have permission to call this constructor.
Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
No matching public constructor was found.
type is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
type is not a valid type.
The constructor to be invoked must be accessible.
Starting with the .NET Framework 2.0 Service Pack 1, this method can be used to access nonpublic types if the caller has been granted ReflectionPermission with the ReflectionPermissionFlag.RestrictedMemberAccess flag and if the grant set of the assembly that contains the nonpublic types is restricted to the caller’s grant set or to a subset thereof. (See Security Considerations for Reflection.)
To use this functionality, your application should target the .NET Framework 3.5 or later.
.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
for the ability to call unmanaged code when creating an instance of a delegate. Associated enumeration: SecurityPermissionFlag.UnmanagedCode
for accessing a nonpublic type when the grant set of the nonpublic type is restricted to the caller's grant set or to a subset thereof. Associated enumeration: ReflectionPermissionFlag.RestrictedMemberAccess
for accessing nonpublic types regardless of their grant sets. Associated enumeration: ReflectionPermissionFlag.MemberAccess