PC Review


Reply
Thread Tools Rate Thread

App version and build date?

 
 
=?Utf-8?B?SlA=?=
Guest
Posts: n/a
 
      6th May 2005
Ive set up my application to read the build version from the <assembly> key
inside my Web.config file using:

string myver = Assembly.GetExecutingAssembly().GetName().Version().ToString()

Is there a way to get the DATE of the build as well?
--
JP
..NET Software Developer
 
Reply With Quote
 
 
 
 
Marc Scheuner [MVP ADSI]
Guest
Posts: n/a
 
      7th May 2005
>Ive set up my application to read the build version from the <assembly> key
>inside my Web.config file using:
>string myver = Assembly.GetExecutingAssembly().GetName().Version().ToString()
>
>Is there a way to get the DATE of the build as well?


You'd have to load the file in question (DLL or EXE) into a FileInfo
and get the creation date off it.

FileInfo oMyFile = new
FileInfo(Assembly.GetExecutingAssembly().Location);

DateTime oBuildDate = oMyFile.CreationTime;
(or possibly oMyFile.CreationTimeUtc; )

HTH
Marc
 
Reply With Quote
 
Sergey Radkevich
Guest
Posts: n/a
 
      7th May 2005
> You'd have to load the file in question (DLL or EXE) into a FileInfo
> and get the creation date off it.


When I deployed another version of assembly several minutes later to the
same place,
the creation time of the file was not changed (only modification time).

So I have used modification time instead.


 
Reply With Quote
 
Michal Dabrowski
Guest
Posts: n/a
 
      9th May 2005
JP wrote:
> Ive set up my application to read the build version from the <assembly> key
> inside my Web.config file using:
>
> string myver = Assembly.GetExecutingAssembly().GetName().Version().ToString()
>
> Is there a way to get the DATE of the build as well?


Here is sample code that retrieves build date from an assembly:

AssemblyName an = Assembly.GetEntryAssembly().GetName();
DateTime date = new DateTime(2000, 1, 1, 0, 0, 0);
date += TimeSpan.FromDays(an.Version.Build) +
TimeSpan.FromSeconds(an.Version.Revision * 2);

HTH

Michal Dabrowski
 
Reply With Quote
 
Marc Scheuner [MVP ADSI]
Guest
Posts: n/a
 
      10th May 2005
>Here is sample code that retrieves build date from an assembly:
>
>AssemblyName an = Assembly.GetEntryAssembly().GetName();
>DateTime date = new DateTime(2000, 1, 1, 0, 0, 0);
>date += TimeSpan.FromDays(an.Version.Build) +
>TimeSpan.FromSeconds(an.Version.Revision * 2);


That *ONLY* works *IF* you *DO NOT* change your assembly version
numbering !

By default, the "build" portion of your assembly will indeed reflect
the build date - but you can change that, if you wish to! And then,
your method here will fail miserably......

Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 
Reply With Quote
 
Michal Dabrowski
Guest
Posts: n/a
 
      10th May 2005
Marc Scheuner [MVP ADSI] wrote:
>>Here is sample code that retrieves build date from an assembly:
>>
>>AssemblyName an = Assembly.GetEntryAssembly().GetName();
>>DateTime date = new DateTime(2000, 1, 1, 0, 0, 0);
>>date += TimeSpan.FromDays(an.Version.Build) +
>>TimeSpan.FromSeconds(an.Version.Revision * 2);

>
>
> That *ONLY* works *IF* you *DO NOT* change your assembly version
> numbering !


That's true, sorry, forgot to mention this. One has to leave the two
asterisks at the end of assembly version number for this method to work.

> By default, the "build" portion of your assembly will indeed reflect
> the build date - but you can change that, if you wish to! And then,
> your method here will fail miserably......


Yes, but looking at file creation date can also produce incorrect result
if the date is not preserved by all programs used between build and
deployment (although I think that most of them preserve it).

Best regards,
Michal Dabrowski
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I meant RC2 Build 5744 is the last build unless ms find more bugs before the RTM build and gold version there only make another build if there more bugs and not ready for RTM Drew Windows Vista General Discussion 4 12th Oct 2006 02:17 PM
Running on version of .NET older than build version C Card Microsoft VC .NET 3 11th Aug 2006 06:45 PM
Build Error -- 'Version 2.0 is not a compatible version' =?Utf-8?B?Um9iIFZldA==?= Microsoft Dot NET Compact Framework 2 10th Sep 2005 11:46 AM
Build Error: 'Version 2.0 is not a compatible version.' in VS2005b =?Utf-8?B?REpvaG5zb24=?= Microsoft Dot NET Compact Framework 0 13th Aug 2005 04:30 PM
File Version and Build Version Maileen Microsoft VB .NET 4 17th Oct 2004 11:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:03 PM.