Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Activator

Assembly: System.Runtime

Inheritance: object → Activator

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

Methods

public static ObjectHandle
CreateInstance​(string assemblyName, string typeName)
Creates an instance of the type whose name is specified, using the named assembly and parameterless constructor.
Returns A handle that must be unwrapped to access the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
assemblyName The name of the assembly where the type named <paramref name="typeName" /> is sought. If <paramref name="assemblyName" /> is <see langword="null" /> , the executing assembly is searched.
typeName The fully qualified name of the type to create an instance of.
public 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.
Returns A handle that must be unwrapped to access the newly created instance, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances with no value.
assemblyName The name of the assembly where the type named <paramref name="typeName" /> is sought. If <paramref name="assemblyName" /> is <see langword="null" /> , the executing assembly is searched.
typeName The fully qualified name of the type to create an instance of.
ignoreCase <see langword="true" /> to specify that the search for <paramref name="typeName" /> is not case-sensitive; <see langword="false" /> to specify that the search is case-sensitive.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="typeName" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that uses <paramref name="bindingAttr" /> and <paramref name="args" /> to seek and identify the <paramref name="typeName" /> constructor. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
args An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args" /> is an empty array or <see langword="null" /> , the constructor that takes no parameters (the parameterless constructor) is invoked.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="typeName" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="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.
public static ObjectHandle
CreateInstance​(string assemblyName, string typeName, object[] activationAttributes)
Creates an instance of the type whose name is specified, using the named assembly and parameterless constructor.
Returns A handle that must be unwrapped to access the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
assemblyName The name of the assembly where the type named <paramref name="typeName" /> is sought. If <paramref name="assemblyName" /> is <see langword="null" /> , the executing assembly is searched.
typeName The fully qualified name of the type to create an instance of.
activationAttributes An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="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.
public static object
CreateInstance​(Type type)
Creates an instance of the specified type using that type's parameterless constructor.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
type The type of object to create.
public static object
CreateInstance​(Type type, bool nonPublic)
Creates an instance of the specified type using that type's parameterless constructor.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
type The type of object to create.
nonPublic <see langword="true" /> if a public or nonpublic parameterless constructor can match; <see langword="false" /> if only a public parameterless constructor can match.
public static object
CreateInstance​(Type type, object[] args)
Creates an instance of the specified type using the constructor that best matches the specified parameters.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances with no value.
type The type of object to create.
args An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args" /> is an empty array or <see langword="null" /> , the constructor that takes no parameters (the parameterless constructor) is invoked.
public 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.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances with no value.
type The type of object to create.
args An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args" /> is an empty array or <see langword="null" /> , the constructor that takes no parameters (the parameterless constructor) is invoked.
activationAttributes An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="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.
public 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.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances with no value.
type The type of object to create.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="type" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that uses <paramref name="bindingAttr" /> and <paramref name="args" /> to seek and identify the <paramref name="type" /> constructor. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
args An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args" /> is an empty array or <see langword="null" /> , the constructor that takes no parameters (the parameterless constructor) is invoked.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="type" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
public 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.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances with no value.
type The type of object to create.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="type" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that uses <paramref name="bindingAttr" /> and <paramref name="args" /> to seek and identify the <paramref name="type" /> constructor. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
args An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args" /> is an empty array or <see langword="null" /> , the constructor that takes no parameters (the parameterless constructor) is invoked.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="type" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="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.
public static ObjectHandle
CreateInstanceFrom​(string assemblyFile, string typeName)
Creates an instance of the type whose name is specified, using the named assembly file and parameterless constructor.
Returns A handle that must be unwrapped to access the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
assemblyFile The name of a file that contains an assembly where the type named <paramref name="typeName" /> is sought.
typeName The name of the type to create an instance of.
public 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.
Returns A handle that must be unwrapped to access the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
assemblyFile The name of a file that contains an assembly where the type named <paramref name="typeName" /> is sought.
typeName The name of the type to create an instance of.
ignoreCase <see langword="true" /> to specify that the search for <paramref name="typeName" /> is not case-sensitive; <see langword="false" /> to specify that the search is case-sensitive.
bindingAttr A combination of zero or more bit flags that affect the search for the <paramref name="typeName" /> constructor. If <paramref name="bindingAttr" /> is zero, a case-sensitive search for public constructors is conducted.
binder An object that uses <paramref name="bindingAttr" /> and <paramref name="args" /> to seek and identify the <paramref name="typeName" /> constructor. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
args An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If <paramref name="args" /> is an empty array or <see langword="null" /> , the constructor that takes no parameters (the parameterless constructor) is invoked.
culture Culture-specific information that governs the coercion of <paramref name="args" /> to the formal types declared for the <paramref name="typeName" /> constructor. If <paramref name="culture" /> is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used.
activationAttributes An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="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.
public 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 parameterless constructor.
Returns A handle that must be unwrapped to access the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
assemblyFile The name of a file that contains an assembly where the type named <paramref name="typeName" /> is sought.
typeName The name of the type to create an instance of.
activationAttributes An array of one or more attributes that can participate in activation. This is typically an array that contains a single <see cref="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.
public static T
CreateInstance​()
Creates an instance of the type designated by the specified generic type parameter, using the parameterless constructor.
Returns A reference to the newly created object, or <see langword="null" /> for <see cref="T:System.Nullable`1" /> instances.
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.