次の方法で共有


AppDomain.BaseDirectory プロパティ

アセンブリを探すためにアセンブリ リゾルバが使用したベース ディレクトリを取得します。

Public Overridable ReadOnly Property BaseDirectory As String  _   Implements _AppDomain.BaseDirectory
[C#]
public virtual string BaseDirectory {get;}
[C++]
public: __property virtual String* get_BaseDirectory();
[JScript]
public function get BaseDirectory() : String;

プロパティ値

アセンブリを探すためにアセンブリ リゾルバが使用するベース ディレクトリ。

実装

_AppDomain.BaseDirectory

例外

例外の種類 条件
AppDomainUnloadedException 操作が、アンロードされたアプリケーション ドメインで試行されています。
SecurityException 呼び出し元に、必要なアクセス許可がありません。

解説

このプロパティは、アセンブリ リゾルバの APPBASE に対応しています。

使用例

 
Imports System
Imports System.Reflection
Imports System.Security.Policy
 'for evidence object

Class ADSetup
   
   Public Shared Sub Main()
      ' Create the application domain setup information.
      Dim domaininfo As 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.
      Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
      
      ' Create appdomain.
      Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo)
      
      ' Write out the 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)
   End Sub 'Main 
End Class 'ADSetup 

[C#] 
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);
    
        
    }
    
}

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;  //for evidence Object

int main() {
   // Create application domain setup information
   AppDomainSetup* domaininfo = new AppDomainSetup();
   domaininfo->ConfigurationFile =
      String::Format(S"file:///{0}ADSetup.exe.config", System::Environment::CurrentDirectory);
   domaininfo->ApplicationBase = String::Format(S"file:///{0}", 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(S"MyDomain", adevidence, domaininfo);

   // Write out application domain information
   Console::WriteLine(S"Host domain: {0}", AppDomain::CurrentDomain->FriendlyName);
   Console::WriteLine(S"child domain: {0}", domain->FriendlyName);
   Console::WriteLine();
   Console::WriteLine(S"Configuration file is: {0}", domain->SetupInformation->ConfigurationFile);
   Console::WriteLine(S"Application Base Directory is: {0}", domain->BaseDirectory);

   AppDomain::Unload(domain);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

AppDomain クラス | AppDomain メンバ | System 名前空間