Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft den AssemblyName für eine angegebene Datei ab.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Function GetAssemblyName ( _
assemblyFile As String _
) As AssemblyName
'Usage
Dim instance As AssemblyNameProxy
Dim assemblyFile As String
Dim returnValue As AssemblyName
returnValue = instance.GetAssemblyName(assemblyFile)
public AssemblyName GetAssemblyName (
string assemblyFile
)
public:
AssemblyName^ GetAssemblyName (
String^ assemblyFile
)
public AssemblyName GetAssemblyName (
String assemblyFile
)
public function GetAssemblyName (
assemblyFile : String
) : AssemblyName
Parameter
- assemblyFile
Die Assemblydatei, für die der AssemblyName abgerufen werden soll.
Rückgabewert
Ein AssemblyName-Objekt, das die angegebene Datei darstellt.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
assemblyFile ist NULL (Nothing in Visual Basic). |
|
assemblyFile ist leer. |
|
assemblyFile wurde nicht gefunden. |
|
Der Aufrufer verfügt nicht über die erforderliche Berechtigung. |
|
assemblyFile ist keine gültige Assembly. |
Hinweise
Dies ist nur möglich, wenn die Datei ein Assemblymanifest enthält. Mit dieser Methode wird die Datei geöffnet und geschlossen.
Beispiel
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
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 'Main
End Class 'AssemblyName_GetAssemblyName
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());
}
}
#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 );
}
import System.*;
import System.Reflection.*;
import System.Text.RegularExpressions.*;
public class AssemblyNameGetAssemblyName
{
public static void main(String[] args)
{
// Get the type of 'System.Object'.
Type myType = Object.class.ToType();
// Get the path of 'System.dll'.
String system = Regex.Replace(myType.get_Assembly().get_CodeBase(),
"mscorlib.dll", "System.dll");
system = Regex.Replace(system, "file:///", "");
// Get the assembly information and display to the console.
AssemblyName myAssemblyName = AssemblyName.GetAssemblyName(system);
Console.WriteLine("\nDisplaying the assembly information of "
+ "'System.dll'\n");
Console.WriteLine(myAssemblyName.ToString());
} //main
} //AssemblyNameGetAssemblyName
.NET Framework-Sicherheit
- FileIOPermission für den Zugriff auf Informationen im Pfad. Zugeordnete Enumeration: FileIOPermissionAccess.PathDiscovery.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
AssemblyNameProxy-Klasse
AssemblyNameProxy-Member
System.Reflection-Namespace