views:

266

answers:

2

I need to display both the AssemblyVersion and the AssemblyFileVersion. In AssemblyInfo.cs, I have: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("2009.8.0")]

However, I only get "2009.8.0" when I reference the above with: public class VersionInfo { public static string AppVersion() { return System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileMajorPart + "." + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileMinorPart + "." + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileBuildPart; } }

How can I display both values? Thanks.

A: 

Application.ProductVersion version will return the AssemblyFileVersion

public string AppVersion() 
{ 
  return Application.ProductVersion + "." + 
    Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
heavyd
A: 

Thank you for the quick response heavyd. However, I wasn't clear. The suggestion you gave works, but what I need is for AssemblyFileVersion to hold the value of the build version, for example 1.0.12345678 Then, I need AssemblyVersion to hold a hard-coded value. Example '2009.8.0'

Thanks again.