.Net Runtime Library for Delphi
Close
Application Domains

Application domains provide a flexible and secure method of isolating running applications.Application domains are usually created and manipulated by run-time hosts. Occasionally, you may want your application to programmatically interact with your application domains, for example, to unload a component without having to stop your application from running.Application domains aid security, separating applications from each other and each other's data. A single process can run several application domains, with the same level of isolation that would exist in separate processes. Running multiple applications within a single process increases server scalability.

In the following code example, you create a new application domain and then load and execute a previously built assembly, HelloWorld.exe, that is stored on drive C.

Delphi
var newDomain: TClrAppDomain; begin // Create the application domain. newDomain := TClrAppDomain.CreateDomain('NewApplicationDomain'); // Load and execute an .Net assembly: newDomain.ExecuteAssembly('c:\HelloWorld.exe'); // Unload the application domain: TClrAppDomain.Unload(newDomain); end.

Application domains have the following properties:

  • An assembly must be loaded into an application domain before it can be executed.

  • Faults in one application domain cannot affect other code running in another application domain.

  • Individual applications can be stopped and code unloaded without stopping the entire process. You cannot unload individual assemblies or types, only entire application domains.

In This Section

How to: Create an Application Domain

Describes how to programmatically create an application domain.

How to: Unload an Application Domain

Describes how to programmatically unload an application domain.

How to: Configure an Application Domain

Provides an introduction to configuring an application domain.

Retrieving Setup Information from an Application Domain

Describes how to retrieve setup information from an application domain.

How to: Load Assemblies into an Application Domain

Describes how to load an assembly into an application domain.

How to: Obtain Type and Member Information from an Assembly

Describes how to retrieve information about an assembly.

How to: Receive First-Chance Exception Notifications

Explains how you can receive a notification that an exception has been thrown, before the common language runtime has begun searching for exception handlers.

Resolving Assembly Loads

Provides guidance on using the AppDomain.AssemblyResolve event to resolve assembly load failures.

Reference

AppDomain/TClrAppDomain

Represents an application domain. Provides methods for creating and controlling application domains.

Related Sections

Emitting Dynamic Methods and Assemblies

Describes how to create dynamic assemblies.

Reflection Overview

Describes how to use the Reflection class to obtain information about an assembly.