Programming with AppDomains

One exposes AppDomains to programmers via the System.AppDomain type. Listing 8.1 shows a subset of the public signature of System.AppDomain. The most important member of this type is the CurrentDomain static property. This property simply fetches the AppDomain reference that is stored in the hard thread's TLS. As a point of interest, one can extract the current soft thread object from the hard thread's TLS via the Thread.CurrentThread property.

Listing 8.1. System.AppDomain (Excerpt)
 using System.Security.Policy; namespace System { public sealed class AppDomain : MarshalByRefObject, _AppDomain, // for COM-based hosting System.Security.IEvidenceFactory { // get "current" domain public static AppDomain CurrentDomain ...

Get Essential .NET, Volume 1: The Common Language Runtime 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.