问题
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.
回答1:
Application.ProductVersion version will return the AssemblyFileVersion
public string AppVersion()
{
return Application.ProductVersion + "." +
Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
来源:https://stackoverflow.com/questions/1111541/how-to-reference-both-assemblyversion-and-assemblyfileversion