Name

Activator

Synopsis

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.)

Public NotInheritable Class Activator
                  ' Public Shared Methods
   Public Shared Function CreateComInstanceFrom( ByVal assemblyName As ...

Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.