. AssemblyInfo .NET CF 3.5. "" Windows ( , )
, , , , Reflection Linq "AssemblyInformationalVersion" ( Visual Studio).
AssemblyInfo.cs( , ):
[assembly: AssemblyInformationalVersion("1.0.0.0 Alpha")]
Then you can use this method to pull out the attribute (I placed it inside the static class in the AssemblyInfo.cs file). The method receives an array of all assembly attributes, then selects the first result corresponding to the attribute name (and gives it to the correct type). After that, you can access the InformationalVersion line.
public static string AssemblyInformationalVersion
{
get
{
AssemblyInformationalVersionAttribute informationalVersion = (AssemblyInformationalVersionAttribute)
(AssemblyInformationalVersionAttribute.GetCustomAttributes(Assembly.GetExecutingAssembly())).Where(
at => at.GetType().Name == "AssemblyInformationalVersionAttribute").First();
return informationalVersion.InformationalVersion;
}
}
To get the normal attribute "AssemblyVersion", I used:
public static string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
source
share