Export (0) Print
Expand All

Activator Class

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

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

[<Sealed>]
[<ComVisibleAttribute(true)>]
[<ClassInterfaceAttribute(ClassInterfaceType.None)>]
type Activator =  
    class 
        interface _Activator 
    end

The Activator type exposes the following members.

  NameDescription
Public methodStatic memberCreateComInstanceFrom(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.
Public methodStatic memberCreateComInstanceFrom(String, String, Byte[], AssemblyHashAlgorithm)Creates an instance of the COM object whose name is specified, using the named assembly file and the default constructor.
Public methodStatic memberCreateInstance(ActivationContext)Creates an instance of the type designated by the specified ActivationContext object.
Public methodStatic memberSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsCreateInstance(Type)Creates an instance of the specified type using that type's default constructor.
Public methodStatic memberCreateInstance(ActivationContext, String[])Creates an instance of the type that is designated by the specified ActivationContext object and activated with the specified custom activation data.
Public methodStatic memberCreateInstance(String, String)Creates an instance of the type whose name is specified, using the named assembly and default constructor.
Public methodStatic memberCreateInstance(Type, Boolean)Creates an instance of the specified type using that type's default constructor.
Public methodStatic memberSupported by Portable Class LibrarySupported in .NET for Windows Store appsCreateInstance(Type, Object[])Creates an instance of the specified type using the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstance(AppDomain, String, String)Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and default constructor.
Public methodStatic memberCreateInstance(String, String, Object[])Creates an instance of the type whose name is specified, using the named assembly and default constructor.
Public methodStatic memberCreateInstance(Type, Object[], Object[])Creates an instance of the specified type using the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo)Creates an instance of the specified type using the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[])Creates an instance of the specified type using the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstance(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])Creates an instance of the type whose name is specified, using the named assembly and the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstance(AppDomain, String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])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.
Public methodStatic memberCreateInstance(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence) Obsolete. Creates an instance of the type whose name is specified, using the named assembly and the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstance(AppDomain, String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence) Obsolete. 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.
Public methodStatic memberSupported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsCreateInstance(T)()Creates an instance of the type designated by the specified generic type parameter, using the parameterless constructor .
Public methodStatic memberCreateInstanceFrom(String, String)Creates an instance of the type whose name is specified, using the named assembly file and default constructor.
Public methodStatic memberCreateInstanceFrom(AppDomain, String, String)Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly file and default constructor.
Public methodStatic memberCreateInstanceFrom(String, String, Object[])Creates an instance of the type whose name is specified, using the named assembly file and default constructor.
Public methodStatic memberCreateInstanceFrom(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])Creates an instance of the type whose name is specified, using the named assembly file and the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstanceFrom(AppDomain, String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])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.
Public methodStatic memberCreateInstanceFrom(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence) Obsolete. Creates an instance of the type whose name is specified, using the named assembly file and the constructor that best matches the specified parameters.
Public methodStatic memberCreateInstanceFrom(AppDomain, String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence) Obsolete. 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.
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberGetObject(Type, String)Creates a proxy for the well-known object indicated by the specified type and URL.
Public methodStatic memberGetObject(Type, String, Object)Creates a proxy for the well-known object indicated by the specified type, URL, and channel data.
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate method_Activator.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers.
Explicit interface implemetationPrivate method_Activator.GetTypeInfoRetrieves the type information for an object, which can then be used to get the type information for an interface.
Explicit interface implemetationPrivate method_Activator.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1).
Explicit interface implemetationPrivate method_Activator.InvokeProvides access to properties and methods exposed by an object.
Top

The CreateInstance method creates an instance of a type defined in an assembly by invoking the constructor that best matches the specified arguments. If no arguments are specified, the constructor that takes no parameters, that is, the default constructor, is invoked.

You must have sufficient permission to search for and call a constructor; otherwise, an exception is thrown. By default, only public constructors are considered during the search for a constructor. If no constructor or default constructor can be found, an exception is thrown.

A binder parameter specifies an object that searches an assembly for a suitable constructor. You can specify your own binder and search criteria. If no binder is specified, a default binder is used. For more information, see the System.Reflection.Binder and System.Reflection.BindingFlags classes.

An evidence parameter affects the security policy and permissions for the constructor. For more information, see the System.Security.Policy.Evidence class.

An instance of a type can be created at a local or remote site. If the type is created remotely, an activation attribute parameter specifies the URI of the remote site. The call to create the instance might pass through intermediary sites before it reaches the remote site. Other activation attributes can modify the environment, or context, in which the call operates at the remote and intermediary sites.

If the instance is created locally, a reference to that object is returned. If the instance is created remotely, a reference to a proxy is returned. The remote object is manipulated through the proxy as if it were a local object.

The GetObject method creates a proxy to a currently running remote object, server-activated well-known object, or XML Web service. You can specify the connection medium, that is, the channel. For more information, see the System.Runtime.Remoting.Channels.ChannelServices class.

Assemblies contain type definitions. The CreateInstance method creates an instance of a type from a currently running assembly. The CreateInstanceFrom method creates an instance from a file that contains an assembly. The CreateComInstanceFrom method creates an instance of a COM object from a file that contains an assembly.

The following example shows how to use the Activator class to dynamically construct objects at run time.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft