AppDomainSetup.ConfigurationFile Property
Gets or sets the name of the configuration file for an application domain.
Assembly: mscorlib (in mscorlib.dll)
The configuration file describes the search rules and configuration data for the application domain. The host that creates the application domain is responsible for supplying this data because the meaningful values vary from situation to situation.
For example, the configuration data for ASP.NET applications is stored for each application, site, and computer, while the configuration data for an executable is stored for each application, user, and computer. Only the host knows the specifics of the configuration data for a particular circumstance.
The following example demonstrates how to use the ConfigurationFile property to specify the path and name of the configuration file for a new application domain.
using System; using System.Reflection; using System.Security.Policy; //for evidence object using System.Security; //for securityzone object using System.Collections; //for IEnumerator class ADCreateDomain { public static void Main() { // Create appdomainsetup information for the new appdomain. AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; domaininfo.ConfigurationFile = System.Environment.CurrentDirectory + "\\ADCreateDomain.exe.config"; domaininfo.ApplicationName = "MyApplication"; domaininfo.LicenseFile = System.Environment.CurrentDirectory + "\\license.txt"; //Create evidence for new appdomain. Evidence adevidence = AppDomain.CurrentDomain.Evidence; //Add the zone and url information to restrict permissions assigned to the appdomain. adevidence.AddHost(new Url("http://www.example.com")); adevidence.AddHost(new Zone(SecurityZone.Internet)); // Create the application domain. AppDomain newDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo); // Write out the application domain information. Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName); Console.WriteLine("child domain: " + newDomain.FriendlyName); Console.WriteLine(); Console.WriteLine("Application base is: " + newDomain.SetupInformation.ApplicationBase); Console.WriteLine("Configuration file is: " + newDomain.SetupInformation.ConfigurationFile); Console.WriteLine("Application name is: " + newDomain.SetupInformation.ApplicationName); Console.WriteLine("License file is: " + newDomain.SetupInformation.LicenseFile); IEnumerator newevidenceenum = newDomain.Evidence.GetEnumerator(); while(newevidenceenum.MoveNext()) Console.WriteLine(newevidenceenum.Current); AppDomain.Unload(newDomain); } }
-
FileIOPermission
for access to the path information. Associated enumeration: FileIOPermissionAccess.PathDiscovery
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.