AssemblyName.GetAssemblyName(String) Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera element AssemblyName dla danego pliku.
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
Parametry
- assemblyFile
- String
Ścieżka zestawu, którego AssemblyName ma zostać zwrócona.
Zwraca
Obiekt reprezentujący dany plik zestawu.
Wyjątki
assemblyFile
to null
.
assemblyFile
jest nieprawidłowy, na przykład zestaw z nieprawidłową kulturą.
assemblyFile
nie można odnaleźć.
Obiekt wywołujący nie ma uprawnień do odnajdywania ścieżek.
assemblyFile
nie jest prawidłowym zestawem.
Zestaw lub moduł został załadowany dwa razy z dwoma różnymi zestawami dowodów.
Przykłady
Poniższy przykład pobiera element AssemblyName dla zestawu na dysku. Nie zostanie on uruchomiony, chyba że ciąg "MyAssembly.exe" zostanie zastąpiony nazwą pliku zestawu (w tym ścieżką, jeśli jest to konieczne) na dysku twardym. Alternatywnie możesz skompilować ten przykład jako "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
Uwagi
Będzie to działać tylko wtedy, gdy plik zawiera manifest zestawu. Ta metoda powoduje otwarcie i zamknięcie pliku, ale zestaw nie jest dodawany do tej domeny.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla