SBVersion

It’s always nice to tell your users that there is a new release when they first load up the application, this way they can download and install it to give them extra functionality or to fix a bug. I have created the following code to allow just that. The principal is very simple, have an XML file with all of your software, versions and release details, put a VB.Net routine on the top and hey-presto, you can now check if there is a new version released.
SBVersion how it works
The XML file I have created features multiple software products, versions, modules and items. This allows for great flexibility if you want one XML file to be the master source for version releases of your developments.

Here’s the configuration of the XML file.

XMLDetails

As you can see, the main parent is “applications”, this has multiple “applications”, these are the products that you release. One application then has multiple “versions”, this allows retaining the history of the applications releases. That release is then broken down into “modules”. The modules are the sections of your application, these are then split even further into “items”, these items are the release notes of that module. Basically we keep a history of what this version does new and fixes, it’s always good to know when you fixed something and when you introduced something new.

XMLContent

Here is an example of how you can fill the details in about your releases (don’t worry, I didn’t release “My first application” to a wide user-base). Note that you must stick to version standards used by .Net as we will be converting them later on. Don’t forget to set the XML file to the location where you have uploaded your new file too.

Now that we have our XML file configured and populated, we now can get on with adding the code to your programme, I’ve written it in VB.Net, but you should be able to convert it to C# using Developer Fusion.

Here’s where I tell you about the SBVersion object, I’ve created this for this very purpose and is available through Springboard Creations. We need to pass the XML file path we created earlier, the current version of the local application and, of course, the application we are comparing. The following section is the routine we use to check the current version to that of the newly released version. Add this to your code along with the reference to SBVersion.

  1. Imports SBControls
  2. Private Sub CheckForUpdates()
  3. Dim oSBVersion As New SBVersion()
  4. ' Pass where to look
  5. oSBVersion.VersionFile = “http://www.domain.co.uk/version.xml”
  6. ' Pass what to look for
  7. oSBVersion.ApplicationName = My.Application.Info.ProductName
  8. ' Pass the local version
  9. oSBVersion.LocalVersion = My.Application.Info.Version
  10. Select Case oSBVersion.CheckVersions()
  11. Case LocalVersionNewer
  12. ' Local version is newer than deployed version
  13. Case VersionsMatch
  14. ' Running the latest version
  15. Case NewVersionAvailable
  16. ' Newer version available
  17. End Select
  18. End Sub

Alter the code above to handle each outcome of the CheckVersions function in your environment. Add the CheckForUpdates call anywhere in your code and there you have it, happy informed users.

Leave a comment