When writing an enterprise level application it’s critical to have a version number. Whether it’s located on the help screen or in debug mode, this will save you so much heartache during QA. The larger the project, the more dependent your team is on the version.
Now that I’m all done ranting to the converted, let’s talk about Silverlight. From my past experience there are two ways to handle versioning:
- Create an abstracted file that contains your version number, or
- Use the Assembly version.
Both have their pros and cons. Option 1 gives you greater control of the version number, however the manual process is tedious. Option 2 enables you to use the Assemblies version, however it provides less control over the version number. Lately I’ve been going with option 2 because it takes one more step out of my deployment process.
To get the version from the Assembly
Doing this is fairly easy once you have the correct block of code. The below block of code shows how to get the version from the Assembly in the MainPage_Loaded method. Do not forget to include the System.Reflection reference.
Given the above block of code, the next question is, where is this assembly version defined? In short, the AssemblyInfo.cs file, which is located in the Properties folder.
At the bottom of the AssemblyInfo.cs file, you’ll see the version info. The directions are in the comments on how to change this. I’ve customized my version to be 0.611.*.
Related posts:



June 12th, 2009 at 7:38 am
[...] Versioning your Silverlight application (Corey Schuman) [...]
June 12th, 2009 at 1:40 pm
[...] Silverlight – Versioning your Silverlight application – Corey Schuman (Suggested by Silverlight News) [...]
June 12th, 2009 at 6:38 pm
Great post, but why bitmaps for your code? I can’t just copy and paste!
June 14th, 2009 at 11:41 am
[...] Silverlight – Versioning your Silverlight application – Corey Schuman (Suggested by Silverlight News) [...]
June 15th, 2009 at 12:30 pm
[...] Versioning your Silverlight application (Corey) [...]
June 23rd, 2009 at 9:12 pm
[...] Corey SchumanVersioning your Silverlight application. [...]
June 23rd, 2009 at 9:26 pm
[...] Corey SchumanVersioning your Silverlight application. [...]
December 22nd, 2009 at 1:30 am
Corey,How do you force the app to grab the latest version once you’ve retrieve the version number and it does not match the latest code release?-Lester
January 27th, 2010 at 8:55 pm
Corey, great post, Thanks. You should check out Reflection.AssemblyName ( http://msdn.microsoft.com/en-us/library/system.reflection.assemblyname(VS.95).aspx ) as a way to get version details from asm.FullName without having to do your own parsing using split – nothing really wrong with doing your own parsing but using the ‘offical’ MS solution is probably a smidge more robust.
May 30th, 2010 at 2:43 pm
AssemblyName assemblyName = new AssemblyName(assembly.FullName);