Any ideas on the best way to.....

hog

Senior Contributor
Joined
Mar 17, 2003
Messages
984
Location
UK
Inform users that a newer version is available?

My theory is this, but was wondering does anyone know/use a better method.

Proposed method:

Users open the application on their PC. When it opens it checks it's version against the version number held within a hidden XML file on the server where all the install files are held. If the version number in the XML is newer the user is informed that a newer version is availble.

1. I presume there is an internal app version number that the app can query without the need for me to create one?

2. Still haven't done anything with XML so unsure as to how easy/hard this would be?

3. Is it possible to give the user a button that when they click it it closes the current application and installs the newer version?

Thx






:)
 
1. System.Reflection.Assembly.GetExecutingAssembly().GetName().Version

2. Pretty easy, you can read an xml stream bit by bit using XmlTextReader or you can load it all at once and query specific nodes for the information you're after. Use the WebClient class to actually download the file.

3. Is the only hard part, a common method is to create a loader program which first checks if a never version has been downloaded (to a temporary file name), and if so deletes the original exe and replaces it with that file. The file is then run.
 
Thn Divil.

So regarding 3. are you saying that only the .exe file would require replacing so no setup.exe would need to be run?
 
It depends what's changing I suppose. If you just have a new exe file with no new dependancies, then yeah, just replacing it will be fine.
 
Thx Divil.

I'm not getting this XML stuff completely at the moment...this is what I have so far:

Visual Basic:
  Private Function CheckVersion() As Boolean

        Dim docVersion As XmlDocument = New XmlDocument

        docVersion.Load(gstrVersionXML)

        Dim rdVersionReader As XmlNodeReader = New XmlNodeReader(docVersion)

        While rdVersionReader.Read

            If rdVersionReader.Name = "currentversion" Then

                MessageBox.Show(rdVersionReader.Value)

            End If

        End While

End Function

This is the XML file content

<?xml version="1.0" encoding="utf-8" ?>
- <mascsversion>
<currentversion>1.0</currentversion>
</mascsversion>

Thing is when I run the code it displays two blank message boxes instead of 1 showing the value 1.0

Where am I going wrong??
 
re XML

I found a nice XML class you can add to your project by Stan Shultes of vbexpert.com
It's pretty simple to use and it comes with instructions, resoning, and an INI converter.
I've uploaded it [HERE]

Read the Readme.txt and the listings.rtf and everything should be pretty easy from there.
 
Well actually your idea doesn't sound so bad, I did something similar for an app we're developing, but only for internal use, if you want to do something outside your network you can use webservices.
1. Create a webservice in your webserver that responds to all the requests made by the users, as simple as you can imagine, install in the server and is ready to be used
2. In your app, first detect the internet connection, if not present handle the error, second, everytime the user uses the app or every 1 hour or 2 (or whenever you think will be OK) query the webservice and check the version.
3. If the version is the same continue, if the version in your server is newer the app sends the user a message to download the new version and install it. Also you can give the user options to download it and install it later...

If your app is made only for Windows XP, you can take advantage of BITS (Background Intelligent Transfer Service), using this you don't need to tell the user that a new version is available, you just download it , and when is ready for install tell the user and install it, like Windows Update. you can have more information about BITS in MSDN, search BITS and you'll get an example well documented on how to do it
 
Thx for the advice chaps, this is how I'm doing it for now:

Visual Basic:
 Private Function CheckVersion() As Boolean

        Dim xPath As XPathNavigator

        Try

            Dim xpathVersion As XPathDocument = New XPathDocument(gstrVersionXML)

            xPath = xpathVersion.CreateNavigator

            xPath.MoveToFirstChild()

            gstrUserVersion = Microsoft.VisualBasic.Left(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString, 3)

            If gstrUserVersion = xPath.Value Then

                Return True

            Else

                gstrNewVersion = xPath.Value
                Return False

            End If

        Catch objException As Exception

            ShowError("Location:   Class frmMain" & ControlChars.CrLf & ControlChars.CrLf & _
                      "Procedure:  CheckVersion() " & ControlChars.CrLf & ControlChars.CrLf & "Error Text: " & _
                      objException.Message)

            Return True

        End Try

    End Function

It's on a LAN so will suffice me thinks:)
 
Back
Top