Activator.CreateInstanceFrom Method (String, String)
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 [C#] public static ObjectHandle CreateInstanceFrom( string assemblyFile, string typeName ); [C++] public: static ObjectHandle* CreateInstanceFrom( String* assemblyFile, String* typeName ); [JScript] 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.
A handle that must be unwrapped to access the newly created instance.
|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.
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