AssemblyName.GetAssemblyName(String) メソッド

定義

指定したファイルの AssemblyName を取得します。

public:
 static System::Reflection::AssemblyName ^ GetAssemblyName(System::String ^ assemblyFile);
public static System.Reflection.AssemblyName GetAssemblyName (string assemblyFile);
static member GetAssemblyName : string -> System.Reflection.AssemblyName
Public Shared Function GetAssemblyName (assemblyFile As String) As AssemblyName

パラメーター

assemblyFile
String

AssemblyName が返される対象のアセンブリのパス。

戻り値

指定したアセンブリ ファイルを表すオブジェクト。

例外

assemblyFilenullです。

assemblyFile が無効です (無効なカルチャを持つアセンブリなど)。

assemblyFile が見つかりません。

呼び出し元に、パス検索アクセス許可がありません。

assemblyFile は有効なアセンブリではありません。

アセンブリまたはモジュールが、2 つの異なる証拠セットを使用して 2 回読み込まれました。

次の例では、ディスク上の AssemblyName アセンブリの を取得します。 文字列 "MyAssembly.exe" をハード ディスク上のアセンブリのファイル名 (必要に応じてパスを含む) に置き換えない限り、実行されません。 または、この例を "MyAssembly.exe" としてコンパイルすることもできます。

#using <system.dll>

using namespace System;
using namespace System::Reflection;
int main()
{
   
   // Replace the string "MyAssembly.exe" with the name of an assembly,
   // including a path if necessary. If you do not have another assembly
   // to use, you can use whatever name you give to this assembly.
   //
   AssemblyName^ myAssemblyName = AssemblyName::GetAssemblyName( "MyAssembly.exe" );
   Console::WriteLine( "\nDisplaying assembly information:\n" );
   Console::WriteLine( myAssemblyName );
}

using System;
using System.Reflection;

public class AssemblyName_GetAssemblyName
{
   public static void Main()
   {
      // Replace the string "MyAssembly.exe" with the name of an assembly,
      // including a path if necessary. If you do not have another assembly
      // to use, you can use whatever name you give to this assembly.
      //
      AssemblyName myAssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe");
      Console.WriteLine("\nDisplaying assembly information:\n");
      Console.WriteLine(myAssemblyName.ToString());
   }
}
Imports System.Reflection

Public Class AssemblyName_GetAssemblyName
   
   Public Shared Sub Main()
      
      ' Replace the string "MyAssembly.exe" with the name of an assembly,
      ' including a path if necessary. If you do not have another assembly
      ' to use, you can use whatever name you give to this assembly.
      '
      Dim myAssemblyName As AssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe")
      Console.WriteLine(vbCrLf & "Displaying assembly information:" & vbCrLf)
      Console.WriteLine(myAssemblyName.ToString())
   End Sub
End Class

注釈

これは、ファイルにアセンブリ マニフェストが含まれている場合にのみ機能します。 このメソッドを使用すると、ファイルは開かれて閉じられますが、アセンブリはこのドメインに追加されません。

適用対象