AssemblyName.GetAssemblyName(String) AssemblyName.GetAssemblyName(String) AssemblyName.GetAssemblyName(String) AssemblyName.GetAssemblyName(String) Method

Definición

Obtiene el nombre de ensamblado (AssemblyName) de un archivo dado.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

Parámetros

assemblyFile
String String String String

Ruta de acceso para el ensamblado cuyo AssemblyName se va a devolver.The path for the assembly whose AssemblyName is to be returned.

Devoluciones

Objeto que representa el archivo de ensamblado determinado.An object that represents the given assembly file.

Excepciones

assemblyFile no es válido, al igual que un ensamblado con una referencia cultural no válida.assemblyFile is invalid, such as an assembly with an invalid culture.

No se ha encontrado assemblyFile.assemblyFile is not found.

El llamador no dispone del permiso de detección de rutas.The caller does not have path discovery permission.

assemblyFile no es un ensamblado válido.assemblyFile is not a valid assembly.

Se cargó un ensamblado o módulo dos veces con dos conjuntos de evidencias diferentes.An assembly or module was loaded twice with two different sets of evidence.

Ejemplos

En el ejemplo siguiente se AssemblyName obtiene el de un ensamblado en el disco.The following example gets the AssemblyName for an assembly on disk. No se ejecutará a menos que reemplace la cadena "myAssembly. exe" por el nombre de archivo de un ensamblado (incluida la ruta de acceso, si es necesario) en el disco duro.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. Como alternativa, puede compilar este ejemplo como "myAssembly. exe".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 'AssemblyName_GetAssemblyName 

Comentarios

Esto solo funcionará si el archivo contiene un manifiesto de ensamblado.This will only work if the file contains an assembly manifest. Este método hace que el archivo se abra y se cierre, pero el ensamblado no se agrega a este dominio.This method causes the file to be opened and closed, but the assembly is not added to this domain.

Seguridad

FileIOPermission
para acceder a la información de la ruta de acceso.for access to information in the path. Enumeración asociada: PathDiscovery.Associated enumeration: PathDiscovery.

Se aplica a