【问题标题】:Automatically incremented revision number doesn't show up in the About Box自动增加的修订号不会显示在“关于”框中
【发布时间】:2010-09-05 21:25:31
【问题描述】:

我有一个小型 VB.NET 应用程序,我正在使用完整版的 Visual Studio 2005。在项目的 Publish 属性中,我将其设置为 Automatically每次发布都会增加修订版

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

我应该改用什么,以便自动递增的修订号显示在 about 框中?

【问题讨论】:

    标签: vb.net visual-studio


    【解决方案1】:

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

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

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

    【讨论】:

    • 这似乎只适用于已部署的应用程序。从 Visual Studio 内部调试时出现部署异常。 (这很好,很容易解决。仅供参考)
    【解决方案2】:

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

    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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • @Pratik 小心 1.0.0.*。我认为它的最大值是 2^16
      【解决方案4】:

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

      C# [程序集:AssemblyVersion("X.Y.")] [程序集:AssemblyFileVersion("X.Y.")]

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

      【讨论】:

        【解决方案5】:

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

        有关更多链接和详细信息,请参阅我对 this question 的回复。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-12-30
          • 2010-09-05
          • 2017-09-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多