Activator

Activator

CF 1.0

System (mscorlib.dll)

sealed class

This class is used to activate objects;
that is, it either creates an object
or obtains a handle to an existing object. This class is generally
used in a variety of specialized conditions. For example,
Activator can create an object within another
AppDomain and hold a handle to that object. This
effectively gives a multidomain container application (such as
ASP.NET) the ability to reach into another
AppDomain to perform tasks within that domain
(such as closing down the AppDomain in the event
of a user request to shut down the application server).

Activator's methods come in two
distinct flavors: CreateInstance( ) and
CreateInstanceFrom( ). These create new objects
when given particular criteria (such as the type to create and the
assembly from which to create it). The GetObject(
) method uses published
System.Runtime.Remoting.RemotingConfiguration data
to locate another object and obtain a handle to it (usually in
preparation for some remote-object method invocations).

All of the methods in Activator return a
System.Runtime.Remoting.ObjectHandle, not the
actual object itself; this object is actually a proxy to the
created/remote object. As such, programmers must call
Unwrap( ) on the returned
ObjectHandle to use the object. (Note that an
explicit downcast is required, since the return value is declared to
be a generic object.)