語言

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 ,該議會將被歸還。

傳回

一個代表指定組合檔案的物件。

例外狀況

assemblyFile 是 null。

assemblyFile 是無效的,例如具有無效文化的組裝。

找不到 assemblyFile。

呼叫者沒有路徑發現權限。

assemblyFile 不是一個有效的組裝。

一個組件或模組會被載入兩次,並攜帶兩組不同的證據。

範例

以下範例為 AssemblyName 磁碟組裝。 除非你將字串「MyAssembly.exe」替換成硬碟中組件的檔名(如有需要,包含路徑),否則它不會執行。 或者,你也可以將此範例編譯為「MyAssembly.exe」。


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

備註

這只有在檔案包含組裝清單時才有效。 此方法會開啟與關閉檔案,但不會將組合語言加入此網域。

適用於