0

I created an AddIn for Autodesk Inventor. Now it is finished and installed on each user workstation. Whenever I have a update for the AddIn the user needs to run the installer to get the latest update, this process I would like to automate that the user ALWAYS has the latest release when working. So the check would happen during the Autodesk Inventor load.

I will check the FileVersionInfo

I can do this using this sample code provided on the MSDN website

Public Shared Sub Main(ByVal args() As String)
    ' Get the file version for the notepad.
    ' Use either of the following two commands.
    FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, "Notepad.exe"))
    Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\Notepad.exe")


    ' Print the file name and version number.
    Console.WriteLine("File: " + myFileVersionInfo.FileDescription + vbLf + "Version number: " + myFileVersionInfo.FileVersion)

End Sub

This results in this output:

Old File: EMIA_001
Version number: 1.0.6113.27965

New File: EMIA_001
Version number: 1.0.6114.20817

But what is the proper way to compare this version number to each other?

Mech_Engineer
  • 535
  • 1
  • 19
  • 46

2 Answers2

1

If they must always use the latest version then just use string comparison on the FileVersion property.

The versions are made up of both a File and a Product version of the format

    FileMajorPart . FileMinorPart . FileBuildPart . FilePrivatePart

Each of these properties can be compared individually if you for instance want to make sure only that Major + Minor are the same.

FloatingKiwi
  • 4,408
  • 1
  • 17
  • 41
1

First, to update automatically add-ins this way, you needs to do 2 things:

  • Close Inventor, since all loaded add-ins will have their DLLs locked.
  • Manage Close Event from Inventor Application and then launch your add-in installer.

Second, for the version comparison, you can use a function, into your add-in, like this one:

    Private Function isUpToDate() As Boolean

        Dim UpToDate As Boolean = True

        Dim FileVersionInfo_LocalDLL As FileVersionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly.Location)
        Dim FileVersionInfo_GlobalDLL As FileVersionInfo = FileVersionInfo.GetVersionInfo("YourGlobalDllFullFileName")

        If String.Compare(FileVersionInfo_LocalDLL.FileVersion, FileVersionInfo_GlobalDLL.FileVersion) < 0 Then
            UpToDate = False
        End If

        Return UpToDate
    End Function
J-SHould
  • 56
  • 6