mscorlib(4.0.0.0) API with additions
System.Activator Class Reference

Contains methods to create types of objects locally or remotely, or obtain references to existing remote objects. This class cannot be inherited. More...

Inheritance diagram for System.Activator:
[legend]
Collaboration diagram for System.Activator:
[legend]

Static Public Member Functions

static object CreateInstance (Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture)
 Creates an instance of the specified type using the constructor that best matches the specified parameters. More...
 
static object CreateInstance (Type type, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
 Creates an instance of the specified type using the constructor that best matches the specified parameters. More...
 
static object CreateInstance (Type type, params object[] args)
 Creates an instance of the specified type using the constructor that best matches the specified parameters. More...
 
static object CreateInstance (Type type, object[] args, object[] activationAttributes)
 Creates an instance of the specified type using the constructor that best matches the specified parameters. More...
 
static object CreateInstance (Type type)
 Creates an instance of the specified type using that type's default constructor. More...
 
static ObjectHandle CreateInstance (string assemblyName, string typeName)
 Creates an instance of the type whose name is specified, using the named assembly and default constructor. More...
 
static ObjectHandle CreateInstance (string assemblyName, string typeName, object[] activationAttributes)
 Creates an instance of the type whose name is specified, using the named assembly and default constructor. More...
 
static object CreateInstance (Type type, bool nonPublic)
 Creates an instance of the specified type using that type's default constructor. More...
 
static T CreateInstance< T > ()
 Creates an instance of the type designated by the specified generic type parameter, using the parameterless constructor. More...
 
static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
 Creates an instance of the type whose name is specified, using the named assembly file and default constructor. More...
 
static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, object[] activationAttributes)
 Creates an instance of the type whose name is specified, using the named assembly file and default constructor. More...
 
static ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityInfo)
 Creates an instance of the type whose name is specified, using the named assembly and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
 Creates an instance of the type whose name is specified, using the named assembly and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityInfo)
 Creates an instance of the type whose name is specified, using the named assembly file and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
 Creates an instance of the type whose name is specified, using the named assembly file and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName)
 Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and default constructor. More...
 
static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityAttributes)
 Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
 Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName)
 Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly file and default constructor. More...
 
static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, Evidence securityAttributes)
 Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly file and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
 Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly file and the constructor that best matches the specified parameters. More...
 
static ObjectHandle CreateInstance (ActivationContext activationContext)
 Creates an instance of the type designated by the specified T:System.ActivationContext object. More...
 
static ObjectHandle CreateInstance (ActivationContext activationContext, string[] activationCustomData)
 Creates an instance of the type that is designated by the specified T:System.ActivationContext object and activated with the specified custom activation data. More...
 
static ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName)
 Creates an instance of the COM object whose name is specified, using the named assembly file and the default constructor. More...
 
static ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
 Creates an instance of the COM object whose name is specified, using the named assembly file and the default constructor. More...
 
static object GetObject (Type type, string url)
 Creates a proxy for the well-known object indicated by the specified type and URL. More...
 
static object GetObject (Type type, string url, object state)
 Creates a proxy for the well-known object indicated by the specified type, URL, and channel data. More...
 

Additional Inherited Members

Detailed Description

Contains methods to create types of objects locally or remotely, or obtain references to existing remote objects. This class cannot be inherited.

Definition at line 21 of file Activator.cs.

Member Function Documentation

◆ CreateComInstanceFrom() [1/2]

static ObjectHandle System.Activator.CreateComInstanceFrom ( string  assemblyName,
string  typeName 
)
static

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

Parameters
assemblyNameThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName or assemblyName is null.
T:System.TypeLoadExceptionAn instance cannot be created through COM. -or- typename was not found in assemblyName .
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.IO.FileNotFoundExceptionassemblyName is not found, or the module you are trying to load does not specify a file name extension.
T:System.MemberAccessExceptionCannot create an instance of an abstract class.-or-This member was invoked with a late-binding mechanism.
T:System.NotSupportedExceptionThe caller cannot provide activation attributes for an object that does not inherit from T:System.MarshalByRefObject.
T:System.ArgumentExceptionassemblyName is the empty string ("").

Definition at line 832 of file Activator.cs.

◆ CreateComInstanceFrom() [2/2]

static ObjectHandle System.Activator.CreateComInstanceFrom ( string  assemblyName,
string  typeName,
byte []  hashValue,
AssemblyHashAlgorithm  hashAlgorithm 
)
static

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

Parameters
assemblyNameThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
hashValueThe value of the computed hash code.
hashAlgorithmThe hash algorithm used for hashing files and generating the strong name.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName or assemblyName is null.
T:System.ArgumentExceptionassemblyName is the empty string ("").
T:System.IO.PathTooLongExceptionAn assembly or module was loaded twice with two different evidences, or the assembly name is longer than MAX_PATH characters.
T:System.IO.FileNotFoundExceptionassemblyName is not found, or the module you are trying to load does not specify a file name extension.
T:System.IO.FileLoadExceptionassemblyName is found but cannot be loaded.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly.
T:System.Security.SecurityExceptionA code base that does not start with "file://" was specified without the required WebPermission.
T:System.TypeLoadExceptionAn instance cannot be created through COM.-or- typename was not found in assemblyName .
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.MemberAccessExceptionAn instance of an abstract class cannot be created. -or-This member was invoked with a late-binding mechanism.
T:System.NotSupportedExceptionThe caller cannot provide activation attributes for an object that does not inherit from T:System.MarshalByRefObject.

Definition at line 860 of file Activator.cs.

◆ CreateInstance() [1/15]

static object System.Activator.CreateInstance ( Type  type,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture 
)
static

Creates an instance of the specified type using the constructor that best matches the specified parameters.

Parameters
typeThe type of object to create.
bindingAttrA combination of zero or more bit flags that affect the search for the type constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the type constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the type constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
Returns
A reference to the newly created object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.ArgumentExceptiontype is not a RuntimeType. -or- type is an open generic type (that is, the P:System.Type.ContainsGenericParameters property returns true).
T:System.NotSupportedExceptiontype cannot be a T:System.Reflection.Emit.TypeBuilder.-or- Creation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported. -or- The assembly that contains type is a dynamic assembly that was created with F:System.Reflection.Emit.AssemblyBuilderAccess.Save.-or-The constructor that best matches args has varargs arguments.
T:System.Reflection.TargetInvocationExceptionThe constructor being called throws an exception.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.Runtime.InteropServices.COMExceptiontype is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
T:System.TypeLoadExceptiontype is not a valid type.

Definition at line 57 of file Activator.cs.

◆ CreateInstance() [2/15]

static object System.Activator.CreateInstance ( Type  type,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes 
)
static

Creates an instance of the specified type using the constructor that best matches the specified parameters.

Parameters
typeThe type of object to create.
bindingAttrA combination of zero or more bit flags that affect the search for the type constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the type constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the type constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A reference to the newly created object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.ArgumentExceptiontype is not a RuntimeType. -or- type is an open generic type (that is, the P:System.Type.ContainsGenericParameters property returns true).
T:System.NotSupportedExceptiontype cannot be a T:System.Reflection.Emit.TypeBuilder.-or- Creation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject. -or- The assembly that contains type is a dynamic assembly that was created with F:System.Reflection.Emit.AssemblyBuilderAccess.Save.-or-The constructor that best matches args has varargs arguments.
T:System.Reflection.TargetInvocationExceptionThe constructor being called throws an exception.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.Runtime.InteropServices.COMExceptiontype is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
T:System.TypeLoadExceptiontype is not a valid type.

Definition at line 90 of file Activator.cs.

◆ CreateInstance() [3/15]

static object System.Activator.CreateInstance ( Type  type,
params object []  args 
)
static

Creates an instance of the specified type using the constructor that best matches the specified parameters.

Parameters
typeThe type of object to create.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
Returns
A reference to the newly created object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.ArgumentExceptiontype is not a RuntimeType. -or- type is an open generic type (that is, the P:System.Type.ContainsGenericParameters property returns true).
T:System.NotSupportedExceptiontype cannot be a T:System.Reflection.Emit.TypeBuilder.-or- Creation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported. -or- The assembly that contains type is a dynamic assembly that was created with F:System.Reflection.Emit.AssemblyBuilderAccess.Save.-or-The constructor that best matches args has varargs arguments.
T:System.Reflection.TargetInvocationExceptionThe constructor being called throws an exception.
T:System.MethodAccessExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MemberAccessException, instead.The caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.MissingMethodExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MissingMemberException, instead.No matching public constructor was found.
T:System.Runtime.InteropServices.COMExceptiontype is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
T:System.TypeLoadExceptiontype is not a valid type.

Definition at line 148 of file Activator.cs.

◆ CreateInstance() [4/15]

static object System.Activator.CreateInstance ( Type  type,
object []  args,
object []  activationAttributes 
)
static

Creates an instance of the specified type using the constructor that best matches the specified parameters.

Parameters
typeThe type of object to create.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A reference to the newly created object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.ArgumentExceptiontype is not a RuntimeType. -or- type is an open generic type (that is, the P:System.Type.ContainsGenericParameters property returns true).
T:System.NotSupportedExceptiontype cannot be a T:System.Reflection.Emit.TypeBuilder.-or- Creation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject. -or- The assembly that contains type is a dynamic assembly that was created with F:System.Reflection.Emit.AssemblyBuilderAccess.Save.-or-The constructor that best matches args has varargs arguments.
T:System.Reflection.TargetInvocationExceptionThe constructor being called throws an exception.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.Runtime.InteropServices.COMExceptiontype is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
T:System.TypeLoadExceptiontype is not a valid type.

Definition at line 176 of file Activator.cs.

◆ CreateInstance() [5/15]

static object System.Activator.CreateInstance ( Type  type)
static

Creates an instance of the specified type using that type's default constructor.

Parameters
typeThe type of object to create.
Returns
A reference to the newly created object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.ArgumentExceptiontype is not a RuntimeType. -or- type is an open generic type (that is, the P:System.Type.ContainsGenericParameters property returns true).
T:System.NotSupportedExceptiontype cannot be a T:System.Reflection.Emit.TypeBuilder.-or- Creation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- The assembly that contains type is a dynamic assembly that was created with F:System.Reflection.Emit.AssemblyBuilderAccess.Save.
T:System.Reflection.TargetInvocationExceptionThe constructor being called throws an exception.
T:System.MethodAccessExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MemberAccessException, instead.The caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.MissingMethodExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MissingMemberException, instead.No matching public constructor was found.
T:System.Runtime.InteropServices.COMExceptiontype is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
T:System.TypeLoadExceptiontype is not a valid type.

Definition at line 204 of file Activator.cs.

◆ CreateInstance() [6/15]

static ObjectHandle System.Activator.CreateInstance ( string  assemblyName,
string  typeName 
)
static

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

Parameters
assemblyNameThe name of the assembly where the type named typeName is sought. For more information, see the Remarks section. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionYou cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.

Definition at line 230 of file Activator.cs.

◆ CreateInstance() [7/15]

static ObjectHandle System.Activator.CreateInstance ( string  assemblyName,
string  typeName,
object []  activationAttributes 
)
static

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

Parameters
assemblyNameThe name of the assembly where the type named typeName is sought. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject.-or- activationAttributes is not a T:System.Runtime.Remoting.Activation.UrlAttributearray.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.
T:System.Reflection.TargetInvocationExceptionAn error occurred when attempting remote activation in a target specified in activationAttributes .

Definition at line 260 of file Activator.cs.

◆ CreateInstance() [8/15]

static object System.Activator.CreateInstance ( Type  type,
bool  nonPublic 
)
static

Creates an instance of the specified type using that type's default constructor.

Parameters
typeThe type of object to create.
nonPublictrue if a public or nonpublic default constructor can match; false if only a public default constructor can match.
Returns
A reference to the newly created object.
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.ArgumentExceptiontype is not a RuntimeType. -or- type is an open generic type (that is, the P:System.Type.ContainsGenericParameters property returns true).
T:System.NotSupportedExceptiontype cannot be a T:System.Reflection.Emit.TypeBuilder.-or- Creation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported. -or- The assembly that contains type is a dynamic assembly that was created with F:System.Reflection.Emit.AssemblyBuilderAccess.Save.
T:System.Reflection.TargetInvocationExceptionThe constructor being called throws an exception.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.Runtime.InteropServices.COMExceptiontype is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.
T:System.TypeLoadExceptiontype is not a valid type.

Definition at line 289 of file Activator.cs.

◆ CreateInstance() [9/15]

static ObjectHandle System.Activator.CreateInstance ( string  assemblyName,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes,
Evidence  securityInfo 
)
static

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

Parameters
assemblyNameThe name of the assembly where the type named typeName is sought. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
securityInfoInformation used to make security policy decisions and grant code permissions.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject. -or-The constructor that best matches args has varargs arguments.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.

Definition at line 400 of file Activator.cs.

◆ CreateInstance() [10/15]

static ObjectHandle System.Activator.CreateInstance ( string  assemblyName,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes 
)
static

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

Parameters
assemblyNameThe name of the assembly where the type named typeName is sought. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject. -or-The constructor that best matches args has varargs arguments.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.

Definition at line 435 of file Activator.cs.

◆ CreateInstance() [11/15]

static ObjectHandle System.Activator.CreateInstance ( AppDomain  domain,
string  assemblyName,
string  typeName 
)
static

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

Parameters
domainThe remote domain where the type named typeName is created.
assemblyNameThe name of the assembly where the type named typeName is sought. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName or domain is null.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract type. -or-This member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.

Definition at line 588 of file Activator.cs.

◆ CreateInstance() [12/15]

static ObjectHandle System.Activator.CreateInstance ( AppDomain  domain,
string  assemblyName,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes,
Evidence  securityAttributes 
)
static

Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and the constructor that best matches the specified parameters.

Parameters
domainThe domain where the type named typeName is created.
assemblyNameThe name of the assembly where the type named typeName is sought. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object. The T:System.Runtime.Remoting.Activation.UrlAttribute specifies the URL that is required to activate a remote object.
securityAttributesInformation used to make security policy decisions and grant code permissions.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiondomain or typeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject. -or-The constructor that best matches args has varargs arguments.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.

Definition at line 628 of file Activator.cs.

◆ CreateInstance() [13/15]

static ObjectHandle System.Activator.CreateInstance ( AppDomain  domain,
string  assemblyName,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes 
)
static

Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and the constructor that best matches the specified parameters.

Parameters
domainThe domain where the type named typeName is created.
assemblyNameThe name of the assembly where the type named typeName is sought. If assemblyName is null, the executing assembly is searched.
typeNameThe fully qualified name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiondomain or typeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyName .
T:System.IO.FileNotFoundExceptionassemblyName was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Runtime.InteropServices.InvalidComObjectExceptionThe COM type was not obtained through Overload:System.Type.GetTypeFromProgID or Overload:System.Type.GetTypeFromCLSID.
T:System.NotSupportedExceptionCreation of T:System.TypedReference, T:System.ArgIterator, T:System.Void, and T:System.RuntimeArgumentHandle types, or arrays of those types, is not supported.-or- activationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject. -or-The constructor that best matches args has varargs arguments.
T:System.BadImageFormatExceptionassemblyName is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.
T:System.IO.FileLoadExceptionAn assembly or module was loaded twice with two different evidences. -or-The assembly name or code base is invalid.

Definition at line 670 of file Activator.cs.

◆ CreateInstance() [14/15]

static ObjectHandle System.Activator.CreateInstance ( ActivationContext  activationContext)
static

Creates an instance of the type designated by the specified T:System.ActivationContext object.

Parameters
activationContextAn activation context object that specifies the object to create.
Returns
A handle that must be unwrapped to access the newly created object.

Definition at line 792 of file Activator.cs.

◆ CreateInstance() [15/15]

static ObjectHandle System.Activator.CreateInstance ( ActivationContext  activationContext,
string []  activationCustomData 
)
static

Creates an instance of the type that is designated by the specified T:System.ActivationContext object and activated with the specified custom activation data.

Parameters
activationContextAn activation context object that specifies the object to create.
activationCustomDataAn array of Unicode strings that contain custom activation data.
Returns
A handle that must be unwrapped to access the newly created object.

Definition at line 807 of file Activator.cs.

◆ CreateInstance< T >()

static T System.Activator.CreateInstance< T > ( )
static

Creates an instance of the type designated by the specified generic type parameter, using the parameterless constructor.

Template Parameters
TThe type to create.
Returns
A reference to the newly created object.
Exceptions
T:System.MissingMethodExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, T:System.MissingMemberException, instead.The type that is specified for T does not have a parameterless constructor.

Definition at line 311 of file Activator.cs.

◆ CreateInstanceFrom() [1/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( string  assemblyFile,
string  typeName 
)
static

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

Parameters
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Security.SecurityExceptionThe caller does have the required T:System.Security.Permissions.FileIOPermission.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.

Definition at line 339 of file Activator.cs.

◆ CreateInstanceFrom() [2/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( string  assemblyFile,
string  typeName,
object []  activationAttributes 
)
static

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

Parameters
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.NotSupportedExceptionactivationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject.
T:System.Security.SecurityExceptionThe caller does have the required T:System.Security.Permissions.FileIOPermission.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.

Definition at line 364 of file Activator.cs.

◆ CreateInstanceFrom() [3/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( string  assemblyFile,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes,
Evidence  securityInfo 
)
static

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

Parameters
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
securityInfoInformation used to make security policy decisions and grant code permissions.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Security.SecurityExceptionThe caller does not have the required T:System.Security.Permissions.FileIOPermission.
T:System.NotSupportedExceptionactivationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.

Definition at line 515 of file Activator.cs.

◆ CreateInstanceFrom() [4/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( string  assemblyFile,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes 
)
static

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

Parameters
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiontypeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Security.SecurityExceptionThe caller does not have the required T:System.Security.Permissions.FileIOPermission.
T:System.NotSupportedExceptionactivationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.

Definition at line 550 of file Activator.cs.

◆ CreateInstanceFrom() [5/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( AppDomain  domain,
string  assemblyFile,
string  typeName 
)
static

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

Parameters
domainThe remote domain where the type named typeName is created.
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiondomain or typeName is null.
T:System.MissingMethodExceptionNo matching public constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Security.SecurityExceptionThe caller does have the required T:System.Security.Permissions.FileIOPermission.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.

Definition at line 698 of file Activator.cs.

◆ CreateInstanceFrom() [6/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( AppDomain  domain,
string  assemblyFile,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes,
Evidence  securityAttributes 
)
static

Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly file and the constructor that best matches the specified parameters.

Parameters
domainThe remote domain where the type named typeName is created.
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
securityAttributesInformation used to make security policy decisions and grant code permissions.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiondomain or typeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Security.SecurityExceptionThe caller does have the required T:System.Security.Permissions.FileIOPermission.
T:System.NotSupportedExceptionactivationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or-The common language runtime (CLR) version 2.0 or later is currently loaded, and assemblyName was compiled for a version of the CLR that is later than the currently loaded version. Note that the .NET Framework versions 2.0, 3.0, and 3.5 all use CLR version 2.0.

Definition at line 737 of file Activator.cs.

◆ CreateInstanceFrom() [7/7]

static ObjectHandle System.Activator.CreateInstanceFrom ( AppDomain  domain,
string  assemblyFile,
string  typeName,
bool  ignoreCase,
BindingFlags  bindingAttr,
Binder  binder,
object []  args,
CultureInfo  culture,
object []  activationAttributes 
)
static

Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly file and the constructor that best matches the specified parameters.

Parameters
domainThe remote domain where the type named typeName is created.
assemblyFileThe name of a file that contains an assembly where the type named typeName is sought.
typeNameThe name of the preferred type.
ignoreCasetrue to specify that the search for typeName is not case-sensitive; false to specify that the search is case-sensitive.
bindingAttrA combination of zero or more bit flags that affect the search for the typeName constructor. If bindingAttr is zero, a case-sensitive search for public constructors is conducted.
binderAn object that uses bindingAttr and args to seek and identify the typeName constructor. If binder is null, the default binder is used.
argsAn array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.
cultureCulture-specific information that governs the coercion of args to the formal types declared for the typeName constructor. If culture is null, the T:System.Globalization.CultureInfo for the current thread is used.
activationAttributesAn array of one or more attributes that can participate in activation. This is typically an array that contains a single T:System.Runtime.Remoting.Activation.UrlAttribute object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
Returns
A handle that must be unwrapped to access the newly created instance.
Exceptions
T:System.ArgumentNullExceptiondomain or typeName is null.
T:System.MissingMethodExceptionNo matching constructor was found.
T:System.TypeLoadExceptiontypename was not found in assemblyFile .
T:System.IO.FileNotFoundExceptionassemblyFile was not found.
T:System.MethodAccessExceptionThe caller does not have permission to call this constructor.
T:System.MemberAccessExceptionCannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
T:System.Reflection.TargetInvocationExceptionThe constructor, which was invoked through reflection, threw an exception.
T:System.Security.SecurityExceptionThe caller does have the required T:System.Security.Permissions.FileIOPermission.
T:System.NotSupportedExceptionactivationAttributes is not an empty array, and the type being created does not derive from T:System.MarshalByRefObject.
T:System.BadImageFormatExceptionassemblyFile is not a valid assembly. -or- assemblyName was compiled for a version of the common language runtime that is later than the version that is currently loaded.

Definition at line 779 of file Activator.cs.

◆ GetObject() [1/2]

static object System.Activator.GetObject ( Type  type,
string  url 
)
static

Creates a proxy for the well-known object indicated by the specified type and URL.

Parameters
typeThe type of the well-known object to which you want to connect.
urlThe URL of the well-known object.
Returns
A proxy that points to an endpoint served by the requested well-known object.
Exceptions
T:System.ArgumentNullExceptiontype or url is null.
T:System.Runtime.Remoting.RemotingExceptiontype is not marshaled by reference and is not an interface.
T:System.MemberAccessExceptionThis member was invoked with a late-binding mechanism.

Definition at line 891 of file Activator.cs.

◆ GetObject() [2/2]

static object System.Activator.GetObject ( Type  type,
string  url,
object  state 
)
static

Creates a proxy for the well-known object indicated by the specified type, URL, and channel data.

Parameters
typeThe type of the well-known object to which you want to connect.
urlThe URL of the well-known object.
stateChannel-specific data or null.
Returns
A proxy that points to an endpoint served by the requested well-known object.
Exceptions
T:System.ArgumentNullExceptiontype or url is null.
T:System.Runtime.Remoting.RemotingExceptiontype is not marshaled by reference and is not an interface.
T:System.MemberAccessExceptionThis member was invoked with a late-binding mechanism.

Definition at line 907 of file Activator.cs.


The documentation for this class was generated from the following file: