Results 1 to 5 of 5

Thread: Version Check

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    353

    Version Check

    Something I came up with just now, I think some may find useful.

    Basically place this in your program form load and if you want a button.

    Checks local assembly version, checks a text file on server which holds the latest version. You can expand on this with a Yes/No or update button where the program closes and it runs the latest version setup.

    vb Code:
    1. Shared Sub VersionCheck()
    2.         Try
    3.             Dim MyProgramVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString
    4.             Dim serverVersionFile As String = textfile-that-holds-version-on-server.txt
    5.             '
    6.             Dim reader As New System.IO.StreamReader(serverVersionFile, Encoding.Default)
    7.             Dim VersionFromFile
    8.             '            
    9.             Do While Not reader.EndOfStream
    10.                 VersionFromFile = reader.ReadLine
    11.             Loop
    12.             reader.Close()
    13.             '
    14.             Dim currentVersion As New Version(MyProgramVersion)
    15.             Dim serverVersion As New Version(VersionFromFile)
    16.             '
    17.             'Update somewhere in program labels for current and server version
    18.             MainWindow.OptionsLabelCurrentVersionResult.Text = currentVersion.ToString
    19.             MainWindow.OptionsLabelServerVersionResult.Text = serverVersion.ToString
    20.             'Throw messagebox with result
    21.             If Version.op_GreaterThan(serverVersion, currentVersion) Then
    22.                 MessageBox.Show("Current Version: " & MyProgramVersion & vbNewLine & "Server Version: " & serverVersion.ToString & vbNewLine & vbNewLine & "Please update to the latest version.", AppTitle)
    23.             End If
    24.         Catch ex As Exception
    25.             MessageBox.Show(ex.Message, AppTitle)
    26.         End Try
    27. End Sub

  2. #2
    Junior Member
    Join Date
    Feb 2014
    Posts
    18

    Re: Version Check

    Good Idea but...if someone changes the assembly version?
    C#/VB.NET Themes/Open Source Projects: http://dotnettotal.comuf.com/

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    353

    Re: Version Check

    The assembly version is changed by you as the owner of the program so is the text file on the server. I'm the sole developer on the app right now, so I found this a handy means to notify the user of an update. Every-time I'm about to release I update both.

  4. #4
    Junior Member
    Join Date
    Feb 2014
    Posts
    18

    Re: Version Check

    Quote Originally Posted by a_ahmed View Post
    The assembly version is changed by you as the owner of the program so is the text file on the server. I'm the sole developer on the app right now, so I found this a handy means to notify the user of an update. Every-time I'm about to release I update both.
    Anyone can change the assembly version using any Hex Editor (as HxD) or Resource Editor (as ResHack).
    I think the best way to do this is using a variable and obfuscate the code.
    C#/VB.NET Themes/Open Source Projects: http://dotnettotal.comuf.com/

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    353

    Re: Version Check

    That is true, but why would anyone be editing the assembly version using a hex editor? I can understand someone could do that but it's beyond the scope of this simply because it's meant to be used a by user to be notified there is a new version to update

    You are right though, alternatively you could set a variable!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width