Display Excel Add In Version using C#

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:

And the result:

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

Answers


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.


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

loginGroup.Label = "v" +    
Assembly.GetAssembly(typeof(<ClassName>)).GetName().Version.ToString();

Need Your Help

How do you distribute a .NET application?

.net installer clr

Before I start developing a desktop application, I was wondering how large the installer will turn out to be if I build it in .NET?

android + javascript : create html dynamically and put javascript in the head tag

javascript android html webview

I have android application and I need to show banner in some specific manner.