visual-studio 自动增加的修订号未显示在关于框中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:21:52  来源:igfitidea点击:

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

vb.netvisual-studio

提问by Mark Biek

I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the Publishproperties of the project, I have it set to Automatically increment revision with each publish.

我有一个小的 VB.NET 应用程序,我正在使用完整版的 Visual Studio 2005。在项目的Publish属性中,我将它设置为Automatically increment revision with each publish

The issue is that it's only incrementing the revision in the Setup files. It doesn't seem to be updating the version number in the About Box (which is the generic, built-in, About Box template). That version number seems to be coming from My.Application.Info.Version.

问题是它只是增加了安装文件中的修订。它似乎没有更新 About Box(这是通用的内置 About Box 模板)中的版本号。该版本号似乎来自My.Application.Info.Version

What should I be using instead so that my automatically incrementing revision number shows up in the about box?

我应该使用什么来代替我的自动递增修订号显示在关于框中?

采纳答案by Stu

Change the code for the About box to

将“关于”框的代码更改为

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

Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish version".

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

回答by rjzii

It took me a second to find this, but I believe this is what you are looking for:

我花了一秒钟才找到这个,但我相信这就是你要找的:

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();
   }
}

It was based upon the code provided at the following site - http://en.csharp-online.net/Display_type_version_number

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

回答by Michael Stum

It's a maximum of 65535 for each of the 4 values, but when using 1.0.* or 1.0.*.*, the Assembly Linker will use a coded timestamp (so it's not a simple auto-increment, and it can repeat!) that will fit 65535.

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

See my answer to this questionfor more links and details.

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

回答by Patrik Svensson

I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*? This should increase the revision number (at least it does in the AssemblyInfo.cs in C#).

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

回答by Jedi Master Spooky

The option you select is only to update the setup number. To update the program number you have to modify the AssemblyInfo.

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

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

C# [程序集:AssemblyVersion("XY ")] [程序集:AssemblyFileVersion("XY")]

VB.NET Assembly: AssemblyVersion("X.Y.*")

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