Build Date

  • Thread starter Thread starter cameron
  • Start date Start date
cameron said:
Is it possible to get the build date, (not the version), of a dll?

-Cam

This won't be too helpful, but I've been sitting here trying for a while
and I can't get it. I know that Jeff Richter says in "Applied Microsoft
..NET Framework Programming" that the build date is in the Windows PE
header part of the Assembly, but I've been picking through one now and
can't figure out how to pull out that information.

Maybe if someone knows how to read the PE header it will take you one
step further.

Regards,
Dustin
 
cameron said:
Is it possible to get the build date, (not the version), of a dll?

-Cam

This would be a bit nasty, but you could run dumpbin /HEADERS <your
file> and parse the output. That gave me the timestamp of the build in
human readable format.

This article explains how the PE header is set up:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndebug/html/msdn_peeringpe.asp

Since the date is the second record in the file you could read the bytes
I guess. It looks like it should work with .EXEs and .DLLs. Not sure
about non-Assembly files. This is all nasty stuff though, in my opinion.
I suspect there's a better way. I may try to write this tomorrow night
if I get some free time.

Regards,
Dustin Aleksiuk
 
Hi Cam,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get the build date of an
assembly programatically. If there is any misunderstanding, please feel
free to let me know.

On approach that I know, is to get it from the version number that VS.NET
has generated automatically. If we use <Assembly: AssemblyVersion("1.0.*")>
as assembly version, VS.NET will generate build number and revision
according to the current date and time. We can try to use the following
code to get the build date.

Private Function BuildDate() As DateTime
'Build dates start from 01/01/2000
Dim result As Date = #1/1/2000#

'Retrieve the version information from the assembly from which this
code is being executed
Dim version As System.Version =
System.Reflection.Assembly.GetExecutingAssembly.GetName.Version

'Add the number of days (build)
result = result.AddDays(version.Build)

'Add the number of seconds since midnight (revision) multiplied by 2
result = result.AddSeconds(version.Revision * 2)

'If we're currently in daylight saving time add an extra hour
If TimeZone.IsDaylightSavingTime(Now,
TimeZone.CurrentTimeZone.GetDaylightChanges(Now.Year)) Then
result.AddHours(1)

Return result
End Function

For more information, please check the following link:

http://dotnetfreak.co.uk/blog/archive/2004/07/08/146.aspx
PS: There is a little mistake in the code provided in the link. I have
fixed it in my code.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Unfortunately, when you have multiple dlls that need to interact with
each other, letting VS generate the version number causes all sorts of
issues. We have gotten around the issues by manually incrementing the
version numbers. Because we are manually incrementing the versions
numbers I want to be able to pull the build date. If we were using the
autoincremented version numbers I would not have a need to pull the
build date. Kind of a catch 22 on that solution.

Thanks for the responce.

-Cam
 
Hi Cam,

I think you can also check the following link.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndebug/htm
l/msdn_peeringpe.asp

According to this article, I think the linker has written the time that
produced this file to the PE header in the TimeDateStamp field of
IMAGE_FILE_HEADER struct. This field holds the number of seconds since
December 31st, 1969, at 4:00 P.M.

A source code to get the information has been provided in this article.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top