La clase de excepción de C # tiene una propiedad de origen que se establece en el nombre del ensamblado de forma predeterminada.
¿Hay otra forma de obtener esta cadena exacta (sin analizar una cadena diferente)?
He probado lo siguiente:
catch(Exception e)
{
string str = e.Source;
//"EPA" - what I want
str = System.Reflection.Assembly.GetExecutingAssembly().FullName;
//"EPA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
str = typeof(Program).FullName;
//"EPA.Program"
str = typeof(Program).Assembly.FullName;
//"EPA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
str = typeof(Program).Assembly.ToString();
//"EPA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
str = typeof(Program).AssemblyQualifiedName;
//"EPA.Program, EPA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
}
c#
.net
reflection
assemblyinfo
Patricio
fuente
fuente

Utilizo la Asamblea para establecer el título del formulario como tal:
fuente
Puedes probar este código que usa la
System.Reflection.AssemblyTitleAttribute.Titlepropiedad:((AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute), false)).Title;fuente
Puede usar la
AssemblyNameclase para obtener el nombre del ensamblado, siempre que tenga el nombre completo del ensamblado:o
Referencia de MSDN - Clase AssemblyName
fuente
Assembly.GetExecutingAssembly().Locationlugar deAssembly.GetExecutingAssembly().FullName.Assembly.GetExecutingAssembly (). Ubicación
fuente