Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AppDomainSetup.ApplicationBase Property

Gets or sets the name of the directory containing the application.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public string ApplicationBase { get; set; }
/** @property */
public final String get_ApplicationBase ()

/** @property */
public final void set_ApplicationBase (String value)

public final function get ApplicationBase () : String

public final function set ApplicationBase (value : String)

Not applicable.

Property Value

A String containing the name of the application base directory.

The application base directory is where the assembly manager begins probing for assemblies.

The ApplicationBase property can influence which permissions are granted to an application domain. For example, an application domain originating from the local computer normally receives full trust based on its location of origin. However, if the ApplicationBase property of that AppDomain is set to the full name of an intranet directory, the ApplicationBase setting restricts the permissions granted to the application domain to a LocalIntranet grant even though the application domain actually originates from the local computer.

The following example demonstrates how to use the ApplicationBase property to set the location where the assembly loader begins probing for assemblies to load into a new application domain.


using System;
using System.Reflection;
using System.Security.Policy;  //for evidence object

class ADSetupInformation
{
	public static void Main()
	{
		//Create the application domain setup information.
		AppDomainSetup domaininfo = new AppDomainSetup();
		domaininfo.ApplicationBase = System.Environment.CurrentDirectory;
		//Create evidence for new appdomain.
		Evidence adevidence = AppDomain.CurrentDomain.Evidence;
		// Create the new application domain using setup information.
		AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);

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

		AppDomain.Unload(domain);
	
		
	}
	
}

import System.*;
import System.Reflection.*;
import System.Security.Policy.*; //for evidence object

class ADSetupInformation
{
    public static void main(String[] args)
    {
        //Create the application domain setup information.
        AppDomainSetup domainInfo = new AppDomainSetup();

        domainInfo.set_ApplicationBase(System.Environment.get_CurrentDirectory());

        //Create evidence for new appdomain.
        Evidence adEvidence = AppDomain.get_CurrentDomain().get_Evidence();

        // Create the new application domain using setup information.
        AppDomain domain = AppDomain.CreateDomain("MyDomain", adEvidence, 
            domainInfo);

        // Write out the application domain information.
        Console.WriteLine("Host domain: " 
            + AppDomain.get_CurrentDomain().get_FriendlyName());
        Console.WriteLine("new child domain: " 
            + domain.get_FriendlyName());
        Console.WriteLine();
        Console.WriteLine("Application base is: " 
            + domain.get_SetupInformation().get_ApplicationBase());

        AppDomain.Unload(domain);
    } //main 
} //ADSetupInformation 

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft