AssemblyName.GetAssemblyName(String) Metoda
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 wartość 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
- assemblyFile
- String
Ścieżka do zestawu, którego AssemblyName ma zostać zwrócona.
Obiekt reprezentujący dany plik zestawu.
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.
Poniższy przykład pobiera AssemblyName element dla zestawu na dysku. Nie zostanie ono uruchomione, chyba że zastąpisz ciąg "MyAssembly.exe" nazwą pliku zestawu (w tym ścieżką, w razie potrzeby) 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
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.
Produkt | Wersje |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Opinia o produkcie .NET
.NET to projekt typu open source. Wybierz link, aby przekazać opinię: