1

I am trying to display the current project version of an excel add in, on the Excel menu bar.

This is a snippet of my code, which is located in the

private void TPFCRibbon_Load(object sender, RibbonUIEventArgs e)
{
    loginGroup.Label = "v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
}

Here is the project version:

Project Version

And the result:

Result

As you can see, it always displays the Version 1.0, what am I doing wrong?

Community
  • 1
  • 1
Lluc
  • 43
  • 8

2 Answers2

2

There are two different version numbers at play here:

  • Assembly version, and
  • ClickOnce publish version

(Note: In a Visual Studio solution you can have multiple assemblies with each having their own assembly version, but there will only be a single publish version when your add-in is deployed.)

Currently, your add-in displays the assembly version. This version number is set in the AssemblyInfo.cs file (in the Properties subfolder of your project) or you can set it via the projects properties pages under Application -> Assembly Information.

If you want to show the ClickOnce publish version, you will need to extract that info from the ClickOnce manifest. Luckily, @cpg already documented very well how to do this: How to display ClickOnce Version number on Windows Forms.

Community
  • 1
  • 1
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
0

Try this because your executing assembly will be Excel if I am not wrong

loginGroup.Label = "v" +    
Assembly.GetAssembly(typeof(<ClassName>)).GetName().Version.ToString();
Kiru
  • 3,489
  • 1
  • 25
  • 46