Activator.CreateComInstanceFrom Method (String, String, Byte, AssemblyHashAlgorithm)
Creates an instance of the COM object whose name is specified, using the named assembly file and the default constructor.
Assembly: mscorlib (in mscorlib.dll)
public static ObjectHandle CreateComInstanceFrom( string assemblyName, string typeName, byte hashValue, AssemblyHashAlgorithm hashAlgorithm )
- Type: System.String
The name of a file that contains an assembly where the type named typeName is sought.
- Type: System.String
The name of the preferred type.
- Type: System.Byte
The value of the computed hash code.
- Type: System.Configuration.Assemblies.AssemblyHashAlgorithm
The hash algorithm used for hashing files and generating the strong name.
Return ValueType: System.Runtime.Remoting.ObjectHandle
A handle that must be unwrapped to access the newly created instance.
typeName or assemblyName is null.
assemblyName is the empty string ("").
An assembly or module was loaded twice with two different evidences, or the assembly name is longer than MAX_PATH characters.
assemblyName is not found, or the module you are trying to load does not specify a file name extension.
assemblyName is found but cannot be loaded.
assemblyName is not a valid assembly.
A code base that does not start with "file://" was specified without the required WebPermission.
An instance cannot be created through COM.
typename was not found in assemblyName.
No matching constructor was found.
An instance of an abstract class cannot be created.
This member was invoked with a late-binding mechanism.
The caller cannot provide activation attributes for an object that does not inherit from MarshalByRefObject.
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.
Starting with the .NET Framework version 2.0 Service Pack 1, this method can be used to create 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 version 3.5. For more information, see .NET Framework 3.5 Architecture.
for reading a URI that begins with "file://". Associated enumeration: FileIOPermissionAccess.Read
for reading a URI that does not begin with "file://".
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 set. Associated enumeration: ReflectionPermissionFlag.MemberAccess
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.