AppDomain.GetAssemblies 메서드

정의

이 애플리케이션 도메인의 실행 컨텍스트에 로드된 어셈블리를 가져옵니다.Gets the assemblies that have been loaded into the execution context of this application domain.

public:
 virtual cli::array <System::Reflection::Assembly ^> ^ GetAssemblies();
public System.Reflection.Assembly[] GetAssemblies ();
abstract member GetAssemblies : unit -> System.Reflection.Assembly[]
override this.GetAssemblies : unit -> System.Reflection.Assembly[]
Public Function GetAssemblies () As Assembly()

반환

이 애플리케이션 도메인에 있는 어셈블리의 배열입니다.An array of assemblies in this application domain.

구현

예외

언로드된 애플리케이션 도메인에서 작업이 시도됩니다.The operation is attempted on an unloaded application domain.

예제

다음 코드 예제에서는 GetAssemblies 메서드를 애플리케이션 도메인에 로드 된 모든 어셈블리의 목록을 가져옵니다.The following code example uses the GetAssemblies method to get a list of all assemblies that have been loaded into the application domain. 그러면 어셈블리가 콘솔에 표시 됩니다.The assemblies are then displayed to the console.

이 코드 예제를 실행 하려면 CustomLibrary.dll라는 어셈블리를 만들거나 GetAssemblies 메서드에 전달 되는 어셈블리 이름을 변경 해야 합니다.To run this code example, you need to create an assembly named CustomLibrary.dll, or change the assembly name that is passed to the GetAssemblies method.

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( "CustomLibrary", asEvidence );
   
   //Make an array for the list of assemblies.
   array<Assembly^>^assems = currentDomain->GetAssemblies();
   
   //List the assemblies in the current application domain.
   Console::WriteLine( "List of assemblies loaded in current appdomain:" );
   System::Collections::IEnumerator^ myEnum = assems->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Assembly^ assem = safe_cast<Assembly^>(myEnum->Current);
      Console::WriteLine( assem );
   }
}

using System;
using System.Reflection;
using System.Security.Policy;

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());
    }
   
}
Imports System.Reflection
Imports System.Security.Policy

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
End Class

적용 대상