Export (0) Print
Expand All

Activator.CreateComInstanceFrom Method (String, String, Byte[], AssemblyHashAlgorithm)

.NET Framework 1.1
Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

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

[Visual Basic]
Overloads Public Shared Function CreateComInstanceFrom( _
   ByVal assemblyName As String, _
   ByVal typeName As String, _
   ByVal hashValue() As Byte, _
   ByVal hashAlgorithm As AssemblyHashAlgorithm _
) As ObjectHandle
[C#]
public static ObjectHandle CreateComInstanceFrom(
 string assemblyName,
 string typeName,
 byte[] hashValue,
 AssemblyHashAlgorithm hashAlgorithm
);
[C++]
public: static ObjectHandle* CreateComInstanceFrom(
 String* assemblyName,
 String* typeName,
 unsigned char hashValue __gc[],
 AssemblyHashAlgorithm hashAlgorithm
);
[JScript]
public static function CreateComInstanceFrom(
   assemblyName : String,
 typeName : String,
 hashValue : Byte[],
 hashAlgorithm : AssemblyHashAlgorithm
) : ObjectHandle;

Parameters

assemblyName
The name of a file that contains an assembly where the type named typeName is sought.
typeName
The name of the preferred type.
hashValue
The value of the computed hash code.
hashAlgorithm
The hash algorithm used for hashing files and generating the strong name.

Return Value

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

Exceptions

Exception Type Condition
ArgumentNullException typeName or assemblyName is a null reference (Nothing in Visual Basic).
ArgumentException assemblyName is the empty string ("").
PathTooLongException An assembly or module was loaded twice with two different evidences, or the assembly name is longer than MAX_PATH characters.
FileNotFoundException assemblyName is not found, or the module you are trying to load does not specify a file name extension.
FileLoadException assemblyName is found but cannot be loaded.
BadImageFormatException assemblyName is not a valid assembly.
SecurityException A codebase that does not start with "file://" was specified without the required WebPermission.
TypeLoadException An instance cannot be created through COM.

-or-

typename was not found in assemblyName.

MissingMethodException No matching constructor was found.
MemberAccessException An instance of an abstract class cannot be created or this member was invoked with a late-binding mechanism.

Remarks

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

A System.Runtime.InteropServices.ComVisibleAttribute attribute with a value of true must be applied either explicitly or by default to the COM type so the CreateComInstanceFrom method can create an instance of that type; otherwise, TypeLoadException is thrown.

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

Requirements

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: 

See Also

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

Show:
© 2015 Microsoft