Recuperar información de instalación de un dominio de aplicaciónRetrieving Setup Information from an Application Domain

Cada instancia de un dominio de aplicación consta de propiedades e información AppDomainSetup.Each instance of an application domain consists of both properties and AppDomainSetup information. Puede recuperar información de instalación de un dominio de aplicación mediante la clase System.AppDomain.You can retrieve setup information from an application domain using the System.AppDomain class. Esta clase proporciona varios miembros que recuperan información de configuración sobre un dominio de aplicación.This class provides several members that retrieve configuration information about an application domain.

También puede consultar el objeto AppDomainSetup del dominio de aplicación para la obtener la información de configuración pasada al dominio al crearse.You can also query the AppDomainSetup object for the application domain to obtain setup information that was passed to the domain when it was created.

En el ejemplo siguiente se crea un dominio de aplicación y, después, se imprimen varios valores de miembro en la consola.The following example creates a new application domain and then prints several member values to the console.

using namespace System;
using namespace System::Reflection;

ref class AppDomain3
{
public:
    static void Main()
    {
        // Create the new application domain.
        AppDomain^ domain = AppDomain::CreateDomain("MyDomain", nullptr);

        // Output to the console.
        Console::WriteLine("Host domain: " + AppDomain::CurrentDomain->FriendlyName);
        Console::WriteLine("New domain: " + domain->FriendlyName);
        Console::WriteLine("Application base is: " + domain->BaseDirectory);
        Console::WriteLine("Relative search path is: " + domain->RelativeSearchPath);
        Console::WriteLine("Shadow copy files is set to: " + domain->ShadowCopyFiles);
        AppDomain::Unload(domain);
    }
};

int main()
{
    AppDomain3::Main();
}
using System;
using System.Reflection;

class AppDomain3
{
    public static void Main()
    {
        // Create the new application domain.
        AppDomain domain = AppDomain.CreateDomain("MyDomain", null);
    
        // Output to the console.
        Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
        Console.WriteLine("New domain: " + domain.FriendlyName);
        Console.WriteLine("Application base is: " + domain.BaseDirectory);
        Console.WriteLine("Relative search path is: " + domain.RelativeSearchPath);
        Console.WriteLine("Shadow copy files is set to: " + domain.ShadowCopyFiles);
        AppDomain.Unload(domain);
    }
}
Imports System
Imports System.Reflection

Class AppDomain3
    Public Shared Sub Main()
        ' Create the new application domain.
        Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", Nothing)

        ' Output to the console.
        Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName)
        Console.WriteLine("New domain: " + domain.FriendlyName)
        Console.WriteLine("Application base is: " + domain.BaseDirectory)
        Console.WriteLine("Relative search path is: " + domain.RelativeSearchPath)
        Console.WriteLine("Shadow copy files is set to: " + domain.ShadowCopyFiles)
        AppDomain.Unload(domain)
    End Sub
End Class

En el ejemplo siguiente se establece y, después, se recupera la información de configuración de un dominio de aplicación.The following example sets, and then retrieves, setup information for an application domain. Observe que AppDomain.SetupInformation.ApplicationBase obtiene la información de configuración.Note that AppDomain.SetupInformation.ApplicationBase gets the configuration information.

using namespace System;
using namespace System::Reflection;

ref class AppDomain5
{
public:
    static void Main()
    {
        // Application domain setup information.
        AppDomainSetup^ domaininfo = gcnew AppDomainSetup();
        domaininfo->ApplicationBase = "f:\\work\\development\\latest";
        domaininfo->ConfigurationFile = "f:\\work\\development\\latest\\appdomain5.exe.config";

        // Creates the application domain.
        AppDomain^ domain = AppDomain::CreateDomain("MyDomain", nullptr, domaininfo);

        // Write the application domain information to the console.
        Console::WriteLine("Host domain: " + AppDomain::CurrentDomain->FriendlyName);
        Console::WriteLine("Child domain: " + domain->FriendlyName);
        Console::WriteLine();
        Console::WriteLine("Application base is: " + domain->SetupInformation->ApplicationBase);
        Console::WriteLine("Configuration file is: " + domain->SetupInformation->ConfigurationFile);

        // Unloads the application domain.
        AppDomain::Unload(domain);
    }
};

int main()
{
    AppDomain5::Main();
}
using System;
using System.Reflection;

class AppDomain5
{
    public static void Main()
    {
        // Application domain setup information.
        AppDomainSetup domaininfo = new AppDomainSetup();
        domaininfo.ApplicationBase = "f:\\work\\development\\latest";
        domaininfo.ConfigurationFile = "f:\\work\\development\\latest\\appdomain5.exe.config";

        // Creates the application domain.
        AppDomain domain = AppDomain.CreateDomain("MyDomain", null, domaininfo);

        // Write the application domain information to the console.
        Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
        Console.WriteLine("Child domain: " + domain.FriendlyName);
        Console.WriteLine();
        Console.WriteLine("Application base is: " + domain.SetupInformation.ApplicationBase);
        Console.WriteLine("Configuration file is: " + domain.SetupInformation.ConfigurationFile);

        // Unloads the application domain.
        AppDomain.Unload(domain);
    }
}
Imports System
Imports System.Reflection

Class AppDomain5
    Public Shared Sub Main()
        ' Application domain setup information.
        Dim domaininfo As New AppDomainSetup()
        domaininfo.ApplicationBase = "f:\work\development\latest"
        domaininfo.ConfigurationFile = "f:\work\development\latest\appdomain5.exe.config"

        ' Creates the application domain.
        Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", Nothing, domaininfo)

        ' Write the application domain information to the console.
        Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName)
        Console.WriteLine("Child domain: " + domain.FriendlyName)
        Console.WriteLine()
        Console.WriteLine("Application base is: " + domain.SetupInformation.ApplicationBase)
        Console.WriteLine("Configuration file is: " + domain.SetupInformation.ConfigurationFile)

        ' Unloads the application domain.
        AppDomain.Unload(domain)
    End Sub
End Class

Vea tambiénSee Also

Programar con dominios de aplicaciónProgramming with Application Domains
Utilizar dominios de aplicaciónUsing Application Domains