Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 How to: Configure an Application Do...
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Developer's Guide
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.

Visual Basic
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
C#
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);
   }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker