AssemblyName.GetAssemblyName(String) メソッド

定義

指定したファイルの AssemblyName を取得します。Gets the AssemblyName for a given file.

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 が返される対象のアセンブリのパス。The path for the assembly whose AssemblyName is to be returned.

戻り値

指定したアセンブリ ファイルを表すオブジェクト。An object that represents the given assembly file.

例外

assemblyFilenullです。assemblyFile is null.

assemblyFile が無効です (無効なカルチャを持つアセンブリなど)。assemblyFile is invalid, such as an assembly with an invalid culture.

assemblyFile が見つかりません。assemblyFile is not found.

呼び出し元に、パス検索アクセス許可がありません。The caller does not have path discovery permission.

assemblyFile は正しいアセンブリではありません。assemblyFile is not a valid assembly.

アセンブリまたはモジュールが、2 つの異なる証拠セットを使用して 2 回読み込まれました。An assembly or module was loaded twice with two different sets of evidence.

次の例ではAssemblyName 、ディスク上のアセンブリのを取得します。The following example gets the AssemblyName for an assembly on disk. 文字列 "MyAssembly" をハードディスク上のアセンブリのファイル名 (必要に応じてパスを含む) に置き換える場合を除き、実行されません。It will not run unless you replace the string "MyAssembly.exe" with the file name of an assembly (including the path, if necessary) on your hard disk. または、この例を "MyAssembly" としてコンパイルすることもできます。Alternatively, you can compile this example as "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

注釈

これは、ファイルにアセンブリマニフェストが含まれている場合にのみ機能します。This will only work if the file contains an assembly manifest. このメソッドを使用すると、ファイルが開かれて閉じられますが、アセンブリはこのドメインに追加されません。This method causes the file to be opened and closed, but the assembly is not added to this domain.

セキュリティ

FileIOPermission
パス内の情報にアクセスします。for access to information in the path. PathDiscovery (関連する列挙体)Associated enumeration: PathDiscovery.

適用対象