This documentation is archived and is not being maintained.

Activator.CreateInstanceFrom Method (String, String)

.NET Framework 1.1

Creates an instance of the type whose name is specified, using the named assembly file and default constructor.

[Visual Basic]
Overloads Public Shared Function CreateInstanceFrom( _
   ByVal assemblyFile As String, _
   ByVal typeName As String _
) As ObjectHandle
public static ObjectHandle CreateInstanceFrom(
 string assemblyFile,
 string typeName
public: static ObjectHandle* CreateInstanceFrom(
 String* assemblyFile,
 String* typeName
public static function CreateInstanceFrom(
   assemblyFile : String,
 typeName : String
) : ObjectHandle;


The name of a file that contains an assembly where the type named typeName is sought.
The name of the preferred type.

Return Value

A handle that must be unwrapped to access the newly created instance.


Exception Type Condition
ArgumentNullException typeName is a null reference (Nothing in Visual Basic).
MissingMethodException No matching public constructor was found.
TypeLoadException typename was not found in assemblyFile.
FileNotFoundException assemblyFile was not found.
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.
TargetInvocationException The constructor, which was invoked through reflection, threw an exception.
SecurityException The caller does have the required FileIOPermission.


Use the ObjectHandle.Unwrap method to unwrap the return value.

For information about other exceptions that can be thrown by invoked methods, see the Exceptions section of the Assembly.LoadFrom and CreateInstance methods.


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

.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
  • FileIOPermission for the ability to search directory paths and read their contents. Associated enumerations: FileIOPermissionAccess/PathDiscovery and Read

See Also

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