none
Programmatically obtain Product Version of Excel Add-In Project with Visual Basic .Net RRS feed

  • Question

  • I am writing to ask if the Product version of an installed Excel Add-In project can be determined programmatically with Visual Basic .Net;

    We have close to 500 business users off site, and an Office Ribbon Excel Add-In project is frequently modified, and published to a SharePoint website - the goal is to determine the actual Product version of the installed Office Ribbon Excel Add-In project, in case any trouble shooting is necessary;

    If an update has been implemented, and published to the SharePoint website - a manual update by the business user is required in order to install the modified Office Ribbon Excel Add-In project to the local machine;

    On my own machine, I am able to locate the Excel Addin project in the Windows Registry, utilizing the following path: HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins;

    The below code displays the Assembly version, rather than the installed Product version:

    MsgBox(Globals.ThisAddIn.GetType().Assembly.GetName().Version.ToString())
    Thanks in advance for any insight;

    robert hellestrae

    Friday, May 3, 2013 7:24 PM

Answers

  • using System.Reflection;
    using System.Diagnostics;
    Assembly assembly = Assembly.GetExecutingAssembly();
    FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
    string version = fileVersionInfo.ProductVersion;


    with regards, Yuri


    • Edited by Yuri Macrovsky Tuesday, May 7, 2013 12:28 PM
    • Marked as answer by rrobhelle Tuesday, May 7, 2013 1:26 PM
    • Unmarked as answer by rrobhelle Tuesday, May 7, 2013 3:17 PM
    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Tuesday, May 7, 2013 12:28 PM
  • Hi Robert,

    Thank you for posting in the MSDN Forum.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Friday, May 10, 2013 9:13 AM
    Moderator
  • As I understand, this falls into VSTO addin deployment. As it's click-once deployment, it check the update automatically, if there're update, it will prompt user to install update.

    At the same time, the Publish version is written to the addin application manifest, while you deploy the addin, you deploy the manifest as well. E.g

    <asmv1:assemblyIdentity name="ExcelAddIn1.dll" version="1.3.2.1"

    The assembly version looks like:

    <assemblyIdentity name="ExcelAddIn1" version="1.0.0.0"

    You can get publish version by extracting version in the manifest.

    Does it help you resove the question?


    Forrest Guo | MSDN Community Support | Feedback to manager

    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Friday, May 10, 2013 2:55 PM
    Moderator
  • Yes, I wrote C# sample and convert it to VB, is it what you need?

    Private Shared Sub Main(ByVal args As String())
        Dim publishVersion As String = String.Empty
        Dim assemblyVersion As String = String.Empty
    
    ' load the application manifest
        Using xmlrdr As XmlReader = XmlReader.Create("ExcelAddIn1.dll.manifest")
            xmlrdr.MoveToContent
            Do While xmlrdr.Read
                If (xmlrdr.Name = "asmv1:assemblyIdentity") Then
                    publishVersion = xmlrdr.Item("version")
                End If
                If ((xmlrdr.Name = "assemblyIdentity") AndAlso (xmlrdr.Item("name") = "ExcelAddIn1")) Then ' there're two occurences of "assemblyIdentity" element, either one is OK
                    assemblyVersion = xmlrdr.Item("version")
                    goto Label_00A5
                End If
            Loop
        End Using
    Label_00A5:
        Console.WriteLine(publishVersion)
        Console.WriteLine(assemblyVersion)
    End Sub
    
     
    
     


    Forrest Guo | MSDN Community Support | Feedback to manager

    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Tuesday, May 14, 2013 1:14 PM
    Moderator

All replies

  • using System.Reflection;
    using System.Diagnostics;
    Assembly assembly = Assembly.GetExecutingAssembly();
    FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
    string version = fileVersionInfo.ProductVersion;


    with regards, Yuri


    • Edited by Yuri Macrovsky Tuesday, May 7, 2013 12:28 PM
    • Marked as answer by rrobhelle Tuesday, May 7, 2013 1:26 PM
    • Unmarked as answer by rrobhelle Tuesday, May 7, 2013 3:17 PM
    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Tuesday, May 7, 2013 12:28 PM
  • Thanks for the feedback;

    The goal is to programmatically, with Visual Basic .Net, capture the Publish Version - rather than the Assembly Information;  Please see the below screen shots for additional information:


    robert hellestrae

    Tuesday, May 7, 2013 3:21 PM
  • Hi Robert,

    Thank you for posting in the MSDN Forum.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Friday, May 10, 2013 9:13 AM
    Moderator
  • As I understand, this falls into VSTO addin deployment. As it's click-once deployment, it check the update automatically, if there're update, it will prompt user to install update.

    At the same time, the Publish version is written to the addin application manifest, while you deploy the addin, you deploy the manifest as well. E.g

    <asmv1:assemblyIdentity name="ExcelAddIn1.dll" version="1.3.2.1"

    The assembly version looks like:

    <assemblyIdentity name="ExcelAddIn1" version="1.0.0.0"

    You can get publish version by extracting version in the manifest.

    Does it help you resove the question?


    Forrest Guo | MSDN Community Support | Feedback to manager

    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Friday, May 10, 2013 2:55 PM
    Moderator
  • Thanks for the feedback;

    I will run a test, and work with the AddIn Application Manifest - programmatically, with Visual Basic .Net;


    robert hellestrae

    Friday, May 10, 2013 4:15 PM
  • Thanks for the feedback;

    To extract details from the manifest, and obtain the publish version - can you provide a sample code snippet in Visual Basic .Net? 


    robert hellestrae

    Monday, May 13, 2013 7:22 PM
  • Yes, I wrote C# sample and convert it to VB, is it what you need?

    Private Shared Sub Main(ByVal args As String())
        Dim publishVersion As String = String.Empty
        Dim assemblyVersion As String = String.Empty
    
    ' load the application manifest
        Using xmlrdr As XmlReader = XmlReader.Create("ExcelAddIn1.dll.manifest")
            xmlrdr.MoveToContent
            Do While xmlrdr.Read
                If (xmlrdr.Name = "asmv1:assemblyIdentity") Then
                    publishVersion = xmlrdr.Item("version")
                End If
                If ((xmlrdr.Name = "assemblyIdentity") AndAlso (xmlrdr.Item("name") = "ExcelAddIn1")) Then ' there're two occurences of "assemblyIdentity" element, either one is OK
                    assemblyVersion = xmlrdr.Item("version")
                    goto Label_00A5
                End If
            Loop
        End Using
    Label_00A5:
        Console.WriteLine(publishVersion)
        Console.WriteLine(assemblyVersion)
    End Sub
    
     
    
     


    Forrest Guo | MSDN Community Support | Feedback to manager

    • Marked as answer by rrobhelle Tuesday, May 14, 2013 1:48 PM
    Tuesday, May 14, 2013 1:14 PM
    Moderator
  • Yes - perfect;  thanks very much;


    robert hellestrae

    Tuesday, May 14, 2013 1:49 PM