关于vb.net:自动递增的修订号未显示在“关于”框中

关于vb.net:自动递增的修订号未显示在“关于”框中

Automatically incremented revision number doesn't show up in the About Box

我有一个小型VB.NET应用程序,正在使用完整版的Visual Studio 2005进行开发。在项目的"发布"属性中,我将其设置为"每次发布时自动递增修订"。

问题在于,它只会增加安装文件中的修订。 它似乎没有更新"关于盒子"(这是通用的内置"关于盒子"模板)中的版本号。 该版本号似乎来自My.Application.Info.Version。

我应该改用什么,以便自动递增的修订号出现在"关于"框中?


我花了一秒钟的时间找到了它,但是我相信这是您想要的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
using System.Reflection;
public class VersionNumber
{
   public static void Main()
   {
      System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
      Version version = assembly.GetName().Version;
      Console.WriteLine ("Version: {0}", version);
      Console.WriteLine ("Major: {0}", version.Major);
      Console.WriteLine ("Minor: {0}", version.Minor);
      Console.WriteLine ("Build: {0}", version.Build);
      Console.WriteLine ("Revision: {0}", version.Revision);
      Console.Read();
   }
}

它基于以下站点提供的代码-http://en.csharp-online.net/Display_type_version_number


将"关于"框的代码更改为

1
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString)

请注意,所有其他答案对于"我如何获得我的程序集版本"都是正确的,而不是所陈述的"我如何显示我的发布版本"问题。


这4个值中的每个最大值最大为65535,但是当使用1.0。*或1.0。*。*时,程序集链接器将使用编码的时间戳记(因此这不是简单的自动递增,并且可以重复!)将适合65535。

有关更多链接和详细信息,请参见我对这个问题的回答。


您选择的选项仅用于更新设置编号。要更新程序号,您必须修改AssemblyInfo。

C#
[assembly:AssemblyVersion(" X.Y。")]
[assembly:AssemblyFileVersion(" X.Y。")]

VB.NET
程序集:AssemblyVersion(" X.Y. *")


我不是VB.NET专家,但是您是否尝试将值设置为例如1.0.0。*?
这应该增加修订号(至少在C#中的AssemblyInfo.cs中这样做)。


推荐阅读