This documentation is archived and is not being maintained.

AppDomainSetup.ConfigurationFile Property

Gets or sets the name of the configuration file for an application domain.

[Visual Basic]
Public Overridable Property ConfigurationFile As String  Implements _
public virtual string ConfigurationFile {get; set;}
public: __property virtual String* get_ConfigurationFile();
public: __property virtual void set_ConfigurationFile(String*);
public function get ConfigurationFile() : String;
public function set ConfigurationFile(String);

Property Value

A String that specifies the name of the configuration file.




Exception Type Condition
SecurityException The caller does not have the required permission.


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.

This property cannot be changed after the AppDomain has finished its first bind.


[Visual Basic] 
Imports System
Imports System.Reflection
Imports System.Security.Policy 'for evidence object
Imports System.Security 'for securityzone object
Imports System.Collections 'for IEnumerator

Class ADCreateDomain
   Public Shared Sub Main()
      ' Create appdomainsetup information for new appdomain.
      Dim domaininfo As New AppDomainSetup()
      domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory
      domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory + "ADCreateDomain.exe.config"
      domaininfo.ApplicationName = "MyApplication"
      domaininfo.LicenseFile = "file:///" + System.Environment.CurrentDirectory + "license.txt"
      'Create evidence for the new appdomain.
      Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
      'Add the zone and url information to restrict permissions assigned to the appdomain.
      adevidence.AddHost(New Url(""))
      adevidence.AddHost(New Zone(SecurityZone.Internet))
      ' Create the application domain.
      Dim newDomain As AppDomain = 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(("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))
      Dim newevidenceenum As IEnumerator = newDomain.Evidence.GetEnumerator()
      While newevidenceenum.MoveNext()
      End While 
   End Sub 'Main 
End Class 'ADCreateDomain 


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 = "file:///" + System.Environment.CurrentDirectory;
        domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory            + "ADCreateDomain.exe.config";
        domaininfo.ApplicationName = "MyApplication";
        domaininfo.LicenseFile = "file:///" + 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(""));
        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("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();



#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;  //for evidence object
using namespace System::Security;  //for securityzone object
using namespace System::Collections;  //for IEnumerator

int main()
    // Create appdomainsetup information for the new appdomain.
    AppDomainSetup* domaininfo = new AppDomainSetup();
    domaininfo->ApplicationBase = String::Format( S"file:///{0}", System::Environment::CurrentDirectory );
    domaininfo->ConfigurationFile = String::Format( S"file:///{0}ADCreateDomain.exe.config", System::Environment::CurrentDirectory );
    domaininfo->ApplicationName = S"MyApplication";
    domaininfo->LicenseFile = String::Format( S"file:///{0}license.txt", System::Environment::CurrentDirectory );

    //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(S""));
    adevidence->AddHost(new Zone(SecurityZone::Internet));

    // Create the application domain.
    AppDomain* newDomain = AppDomain::CreateDomain(S"MyDomain", adevidence, domaininfo);

    // Write out the application domain information.
    Console::WriteLine(S"Host domain: {0}", AppDomain::CurrentDomain->FriendlyName);
    Console::WriteLine(S"child domain: {0}", newDomain->FriendlyName);
    Console::WriteLine(S"Application base is: {0}", newDomain->SetupInformation->ApplicationBase);
    Console::WriteLine(S"Configuration file is: {0}", newDomain->SetupInformation->ConfigurationFile);
    Console::WriteLine(S"Application name is: {0}", newDomain->SetupInformation->ApplicationName);
    Console::WriteLine(S"License file is: {0}", newDomain->SetupInformation->LicenseFile);

    IEnumerator* newevidenceenum = newDomain->Evidence->GetEnumerator();


[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

AppDomainSetup Class | AppDomainSetup Members | System Namespace