Share via


How to: Configure an Application DomainĀ 

You can provide the common language runtime with configuration information for a new application ___domain using the AppDomainSetup class. When creating your own application domains, the most important property is ApplicationBase. The other AppDomainSetup properties are used mainly by runtime hosts to configure a particular application ___domain.

The ApplicationBase property defines the root directory of the application. When the runtime needs to satisfy a type request, it probes for the assembly containing the type in the directory specified by the ApplicationBase property.

NoteNote

A new application ___domain inherits only the ApplicationBase property of the creator.

The following example creates an instance of the AppDomainSetup class, uses this class to create a new application ___domain, writes the information to console, and then unloads the application ___domain.

Example

Imports System
Imports System.Reflection
Class AppDomain4
   Public Shared Sub Main()
      ' Create application ___domain setup information.
      Dim domaininfo As New AppDomainSetup()
      domaininfo.ApplicationBase = "f:\work\development\latest"
      
      ' Create the application ___domain.
      Dim ___domain As AppDomain = AppDomain.CreateDomain("MyDomain", Nothing, domaininfo)
      
      ' Write application ___domain information to the console.
      Console.WriteLine(("Host ___domain: " + AppDomain.CurrentDomain.FriendlyName))
      Console.WriteLine(("child ___domain: " + ___domain.FriendlyName))
      Console.WriteLine(("Application base is: " + ___domain.SetupInformation.ApplicationBase))
      
      ' Unload the application ___domain.
      AppDomain.Unload(___domain)
   End Sub 'Main
End Class 'AppDomain4
using System;
using System.Reflection;
class AppDomain4
{
public static void Main()
{
 // Create application ___domain setup information.
 AppDomainSetup domaininfo = new AppDomainSetup();
 domaininfo.ApplicationBase = "f:\\work\\development\\latest";

 // Create the application ___domain.
 AppDomain ___domain = AppDomain.CreateDomain("MyDomain", null, domaininfo);

// Write application ___domain information to the console.
            Console.WriteLine("Host ___domain: " + AppDomain.CurrentDomain.FriendlyName);
            Console.WriteLine("child ___domain: " + ___domain.FriendlyName);
            Console.WriteLine("Application base is: " + ___domain.SetupInformation.ApplicationBase);

// Unload the application ___domain.
AppDomain.Unload(___domain);
   }
}

See Also

Concepts

Programming with Application Domains

Other Resources

Hosting the Common Language Runtime
Using Application Domains