Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

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

Value types in the System namespace

Figure 26-5. Value types in the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Joe Mayo

Publisher Resources

ISBN: 0596005261Catalog PageErrata