Version information in a dll or exe

Does anyone now how to add something to the version info block in a .net application?  The default stuff is defined in the generated AssemblyInfo.vb file like this <Assembly: AssemblyTitle("some title")>.  I have a custom piece of version info that I always add to anything built in VC++ 6.0 where it is easy to do so.  I suppose I've got to add it to this AssemblyInfo.vb file somehow.  

Hopefully this is relatively simple, but I just don't have any more time to figure it out.  Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Didnt get your question exactly, but here is the things which I know..
Following Line defines the version in assemblyinfo.vb file.

<Assembly: AssemblyVersion("0.1.1")>

AssemblyVersion      Effective Value
not present
1.2.*            1.2.D.S
1.2.3.*            1.2.3.S

D = number of days since February 1, 2000
S = number of seconds since midnight / 2

kpcapelAuthor Commented:
Let me see if I can clarify my question.  Let's say that I have a dll.  If you right click on the dll in Windows Explorer, then click properties, and then click the version tab, you will see the version information.  By default a dll built with .net will display the following...

Assembly Version
File Version
Internal Name
Legal Trademarks
Original File name
Product Name
Product Version

What I want to do is add a custom item to this.  As I said, its quite easy with VC++ 6.0, you just edit resource file and add it.  Trying to do it with is not nearly so obvious.
I dont know about this... but I guess this should be done with the metadata...and thus reflection...

proper direction may be usage of custom attributes.

Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

kpcapelAuthor Commented:
yes - .net SDK says that it is - and this is what I've been playing with but no success.
seems fun to do this.. I m also working on it. will get back to you if succeed...
I have managed to add the attrib in manifest...but still it is not showing up in right click...

I have created this class and now u can place that attrib in your assembly...and also it is there in manifest

<AttributeUsage(AttributeTargets.Assembly)> Public NotInheritable Class myassmattrib
    Inherits System.Attribute
    Public _info As String
    Public Sub New(ByVal info As String)
        _info = info
    End Sub
End Class

if u go any further then write me back...

It can be helpful to me in  going to right direction, if you can tell me how u had done that in VC...

kpcapelAuthor Commented:
In VC++ it is quite easy.  To the project resources you first add a version info block.  That gives you the default stuff.  The resource tab in the VC++ IDE provides a user friendly way to change the various fields in the version info.  If you'd like to add a custom one, you manually edit the underlying .rc file outside of the IDE.  The .rc file is a generated file, but it can be modified.  Below is an excerpt from one of my resource files.  Notice the VALUE "BuildDate" field.  That was manually added and is viewable from Explorer in the compiled DLL.  Names have been changed to protect the guilty. :)

#ifdef _DEBUG
 FILEOS 0x40004L
    BLOCK "StringFileInfo"
        BLOCK "040904b0"
            VALUE "BuildDate", "10/14/2003\0"
            VALUE "Comments", "\0"
            VALUE "CompanyName", "My company\0"
            VALUE "FileDescription", "My DLL\0"
            VALUE "FileVersion", "\0"
            VALUE "InternalName", "CodeName X\0"
            VALUE "LegalCopyright", "Copyright© My Company 2003\0"
            VALUE "LegalTrademarks", "My Company®, My Product®\0"
            VALUE "OriginalFilename", "mydll.dll\0"
            VALUE "PrivateBuild", "\0"
            VALUE "ProductName", "My Product®\0"
            VALUE "ProductVersion", "\0"
            VALUE "SpecialBuild", "\0"
    BLOCK "VarFileInfo"
        VALUE "Translation", 0x409, 1200
kpcapelAuthor Commented:
Anybody got a line on this?  I've increased the points.

sorry to be late. it was week end.

I have come up with few things...

It seems this is not a possible.

I will explain why I came to this point. For this we need to understand the PE Executable format generated by .NET Compilers.

Its like this..

Section:                PE/COFF headers

Section:               CLR Header

Section:               CLR Data (Metadata + IL)

Section:               Native Image Section (.data, .rdata, .rsrc, .text)

I have used ildasm and dumpbin to check the files generated by using reflections and custom atributes, you can easily play with CLR Header and CLR Data...but u do not have access to NIS and PE Headers section.

this means, compilers uses the #pragma to generate this custom sections in PE files, and they reserve their rights to modify main sections of the PE files..they dont give us that access...

unfortunately, the properties we are trying to access, are stored in native image section.and we dont have access to it. (you can verify by using ildasm, and opening exe directly into notepad. dumpbin will also help u.

now in VC++ you can do this as VC++ compiler allows u to play with PE file format...

If still you want to do this, then you can do this with the unsafe code in managed extension for c++.. but not in any of the managed code.

to check the arguments I have made, follow this step.

Create a console application: helloworld.exe
which writes helloworld on screen.
go to asssembly info and write a string in AssemblyTitle which u can later  seach.

use dumpbin.exe for this exe generated file. find the AssemblyTitle u have given in the output of dumpbin.

u can see that versioninfo block is in  RAW DATA #3 under SECTION HEADER #3. now all we can play with is SECTION HEADER #1.

I hope this is clear enough. I would love to continue this thread. so will wait for your inputs. or you can do this by closing this thread and we will continue on our personal mail address...what ever u prefer.

kpcapelAuthor Commented:
Interesting.  Let me digest what you've found for a bit.
kpcapelAuthor Commented:

For the most part, I can confirm what you've said.  However, I'm not ready to believe that this cannot be done in .Net, especially because its so easy in VS6.

I opened a support case with Microsoft on this, and I'm working with the .Net developers.  I didn't want to pay actual money, but I need this.  When I'm through working with them (probably a few days), I'll post all the information here for everyone.
kpcapelAuthor Commented:
Here is the solution with help from Microsoft.  This is not a particularly pretty process, but it works.  After figuring out all the necessary options for my project in the command-line compiler, I got the result I was looking for.

1. Build the DLL in VS .NET (this is to get the initial resources created from the assembly info).
2. Open the DLL in VS .NET.
3. go to File -> Save <dll> As.
4. In the Save As dialog change the Save As type to a Resource Script (.rc).
5. Edit the .rc file to add your customer VALUE.
6. Use rc.exe (with /r switch to generate .res file) to compile the .rc file into a .res file. (Use .net Command Prompt)

7. Use vbc.exe (command-line) with the /win32resource option to embed the .res file ( or csc with the /win32res option )

oh ok.. I was going on wrong track then... I was working on AL.exe... :-(

any way..good to know this.

thanks for the info too.

PAQed, with points refunded (500)

EE Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.