How to reference both ASSEMBLYVERSION and ASSEMBLYFILEVERSION?

戏子无情 提交于 2020-01-05 13:26:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!