次の方法で共有


AppDomain.GetAssemblies メソッド

アプリケーション ドメインに読み込まれているアセンブリを取得します。

Public Overridable Function GetAssemblies() As Assembly() Implements _   _AppDomain.GetAssemblies
[C#]
public virtual Assembly[] GetAssemblies();
[C++]
public: virtual Assembly* GetAssemblies() [];
[JScript]
public function GetAssemblies() : Assembly[];

戻り値

アプリケーション ドメイン内のアセンブリの配列。

実装

_AppDomain.GetAssemblies

例外

例外の種類 条件
AppDomainUnloadedException 操作が、アンロードされたアプリケーション ドメインで試行されています。

使用例

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

Class ADGetAssemblies
   
   
   Public Shared Sub Main()
      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      'Provide the current application domain evidence for the assembly.
      Dim asEvidence As Evidence = currentDomain.Evidence
      'Load the assembly from the application directory using a simple name.
     
      'Create an assembly called CustomLibrary to run this sample.
      currentDomain.Load("CustomLibrary", asEvidence)
      
      'Make an array for the list of assemblies.
      Dim assems As [Assembly]() = currentDomain.GetAssemblies()
      
      'List the assemblies in the current application domain.
      Console.WriteLine("List of assemblies loaded in current appdomain:")
      Dim assem As [Assembly]
      For Each assem In  assems
         Console.WriteLine(assem.ToString())
      Next assem
   End Sub 'Main 
End Class 'ADGetAssemblies 

[C#] 
using System;
using System.Reflection;
using System.Security.Policy;  //for Evidence object

class ADGetAssemblies 
{

    public static void Main() 
    {
        AppDomain currentDomain = AppDomain.CurrentDomain;
        //Provide the current application domain evidence for the assembly.
        Evidence asEvidence = currentDomain.Evidence;
        //Load the assembly from the application directory using a simple name.

        //Create an assembly called CustomLibrary to run this sample.
        currentDomain.Load("CustomLibrary",asEvidence);

        //Make an array for the list of assemblies.
        Assembly[] assems = currentDomain.GetAssemblies();
    
        //List the assemblies in the current application domain.
        Console.WriteLine("List of assemblies loaded in current appdomain:");
            foreach (Assembly assem in assems)
                Console.WriteLine(assem.ToString());
    }
   
}

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

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

int main() {
    AppDomain*  currentDomain = AppDomain::CurrentDomain;
    //Provide the current application domain evidence for the assembly.
    Evidence* asEvidence = currentDomain->Evidence;
    //Load the assembly from the application directory using a simple name.

    //Create an assembly called CustomLibrary to run this sample.
    currentDomain->Load(S"CustomLibrary", asEvidence);

    //Make an array for the list of assemblies.
    Assembly*  assems[] = currentDomain->GetAssemblies();

    //List the assemblies in the current application domain.
    Console::WriteLine(S"List of assemblies loaded in current appdomain:");
    System::Collections::IEnumerator* myEnum = assems->GetEnumerator();

    while (myEnum->MoveNext()) {
        Assembly* assem = __try_cast<Assembly*>(myEnum->Current);
        Console::WriteLine(assem);
    }
}

[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 名前空間