In The Mix

As a SharePoint architect I have the business behind me and the Developers and IT Pro on my shoulders.

Getting Build Date and Time from Assembly Version December 28, 2010

Filed under: .NET,Silverlight — fmuntean @ 10:43 pm

When you use the following format for Assembly Version Attribute 
[assembly: AssemblyVersion(“1.0.*”)] the build number and revision are automatically generated for you when building the application.

It turns out that that a formula based on DateTime.Now is used to generate those numbers.

So to get the DateTime time stamp when the assembly was build all you have to do is:

Code Snippet
  1. Version v = ParseVersionNumber(Assembly.GetExecutingAssembly());
  2.            return new DateTime((v.Build – 1) * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2).AddYears(1999);
Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s