This documentation is archived and is not being maintained.

AppDomain.BaseDirectory Property

Gets the base directory that the assembly resolver used to probe for assemblies.

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

public string BaseDirectory { get; }
/** @property */
public final String get_BaseDirectory ()

public final function get BaseDirectory () : String

Property Value

The base directory that the assembly resolver uses to probe for assemblies.

Exception typeCondition

AppDomainUnloadedException

Operations are attempted on an unloaded application domain.

This property corresponds to the assembly resolver's APPBASE.

using System;
using System.Reflection;
using System.Security.Policy;  //for evidence object
class ADSetup
{
	public static void Main()
	{
		// Create application domain setup information
		AppDomainSetup domaininfo = new AppDomainSetup();
		domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory + "ADSetup.exe.config";
		domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory;

		//Create evidence for the new appdomain from evidence of the current application domain
		Evidence adevidence = AppDomain.CurrentDomain.Evidence;

		// Create appdomain
		AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);

		// Write out application domain information
		Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
		Console.WriteLine("child domain: " + domain.FriendlyName);
		Console.WriteLine();
		Console.WriteLine("Configuration file is: " + domain.SetupInformation.ConfigurationFile);
		Console.WriteLine("Application Base Directory is: " + domain.BaseDirectory);


		AppDomain.Unload(domain);
	
		
	}
	
}

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

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

        domainInfo.set_ConfigurationFile("file:///" 
            + System.Environment.get_CurrentDirectory() + "ADSetup.exe.config");
        domainInfo.set_ApplicationBase("file:///" 
            + System.Environment.get_CurrentDirectory());

        // Create evidence for the new appdomain from evidence of the 
        // current application domain
        Evidence adEvidence = AppDomain.get_CurrentDomain().get_Evidence();

        // Create appdomain
        AppDomain domain = AppDomain.CreateDomain("MyDomain", adEvidence, 
            domainInfo);

        // Write out application domain information
        Console.WriteLine("Host domain: " 
            + AppDomain.get_CurrentDomain().get_FriendlyName());
        Console.WriteLine("child domain: " 
            + domain.get_FriendlyName());
        Console.WriteLine();
        Console.WriteLine("Configuration file is: " 
            + domain.get_SetupInformation().get_ConfigurationFile());
        Console.WriteLine("Application Base Directory is: " 
            + domain.get_BaseDirectory());
        AppDomain.Unload(domain);
    } //main 
} //ADSetup 

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: