CreateComInstanceFrom Method (String, String)
Collapse the table of content
Expand the table of content

Activator.CreateComInstanceFrom Method (String, String)

Creates an instance of the COM object whose name is specified, using the named assembly file and the constructor that best matches the specified parameters.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static ObjectHandle CreateComInstanceFrom (
	string assemblyName,
	string typeName
)
public static ObjectHandle CreateComInstanceFrom (
	String assemblyName, 
	String typeName
)
public static function CreateComInstanceFrom (
	assemblyName : String, 
	typeName : String
) : 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.

Return Value

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

Exception typeCondition

ArgumentNullException

typeName is a null reference (Nothing in Visual Basic).

TypeLoadException

An instance cannot be created through COM.

-or-

typename was not found in assemblyName.

MissingMethodException

No matching constructor was found.

FileNotFoundException

assemblyName is not found, or the module you are trying to load does not specify a file name extension.

MemberAccessException

Cannot create an instance of an abstract class or this member was invoked with a late-binding mechanism.

NotSupportedException

The caller cannot provide activation attributes for an object that does not inherit from MarshalByRefObject.

ArgumentException

assemblyName is the empty string ("").

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.

  • ReflectionPermission  for the ability to invoke operations on all type members. Associated enumeration: MemberAccess

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2016 Microsoft