如何引用ASSEMBLYVERSION和ASSEMBLYFILEVERSION? [英] How to reference both ASSEMBLYVERSION and ASSEMBLYFILEVERSION?

查看:327
本文介绍了如何引用ASSEMBLYVERSION和ASSEMBLYFILEVERSION?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示AssemblyVersion和AssemblyFileVersion。在AssemblyInfo.cs中,我有:
[assembly:AssemblyVersion(1.0。*)]
[assembly:AssemblyFileVersion(2009.8.0)]

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

但是,我只得到2009.8.0当我引用上面的:
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;
}
}

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.

推荐答案

Application.ProductVersion 版本将返回AssemblyFileVersion

Application.ProductVersion version will return the AssemblyFileVersion

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

这篇关于如何引用ASSEMBLYVERSION和ASSEMBLYFILEVERSION?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆