In my c# applications I usually get the version (to show the customer) using the following code:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Vers
First, I think it's more apt to use the assembly's file version info for conveying the application version to the user. See http://techblog.ranjanbanerji.com/post/2008/06/26/Net-Assembly-Vs-File-Versions.aspx
Second, what about doing this:
using System;
using System.Linq;
using System.Reflection;
public static class AssemblyExtensions
{
public static Version GetFileVersion(this Assembly assembly)
{
var versionString = assembly.GetCustomAttributes(false)
.OfType()
.First()
.Version;
return Version.Parse(versionString);
}
}