Version and compile date in about screen

CheapCall About ScreenWant to show your user version and compile date in your about box without always modifing them somewhere in your code? Here’s your answer.
Use the default project properties (right click on the project -> properties, select Application tab, click on Assembly Information…) to set version information. The star in Assembly Version is required as it is the magic part, that allows use to retrieve the compile date.
Keep in mind, you are able to specify MajorVersion and MinorVersion but not Revision and Build.
Assembly Information Dialog from Visual Studio 2010 SP1

public static string GetCompiledVersion()
{
 var version = new System.Version(
    Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('=')[1]
 );

 DateTime compiledOn = new DateTime(
    version.Build * TimeSpan.TicksPerDay + version.Revision * TimeSpan.TicksPerSecond * 2
 ).AddYears(1999);

 return string.Format("{0}.{1} ({2})", version.Major, version.Minor, compiledOn.ToShortDateString());
}

Quite simple snippet (exception handling is not included). Feel free to adopt it in any way you like.

- tobias

About Tobias Mueller

The next best geek...
This entry was posted in .net, Windows Phone 7 and tagged , , . Bookmark the permalink.

Comments are closed.