Solved

Version information in a vb.net dll or exe

Posted on 2003-11-13
16
730 Views
Last Modified: 2007-12-19
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.
0
Comment
Question by:kpcapel
  • 7
  • 7
16 Comments
 
LVL 4

Expert Comment

by:NetPointer
Comment Utility
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      0.0.0.0
1            1.0.0.0
1.2            1.2.0.0
1.2.3            1.2.3.0
1.2.3.4            1.2.3.4
1.2.*            1.2.D.S
1.2.3.*            1.2.3.S

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

HTH
NetPointer
0
 

Author Comment

by:kpcapel
Comment Utility
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
Comments
Company
File Version
Internal Name
Language
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 vb.net is not nearly so obvious.
0
 
LVL 4

Expert Comment

by:NetPointer
Comment Utility
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.

HTH
NetPointer
0
 

Author Comment

by:kpcapel
Comment Utility
yes - .net SDK says that it is - and this is what I've been playing with but no success.
0
 
LVL 4

Expert Comment

by:NetPointer
Comment Utility
seems fun to do this.. I m also working on it. will get back to you if succeed...
0
 
LVL 4

Expert Comment

by:NetPointer
Comment Utility
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...

Regards,
NetPointer
0
 
LVL 4

Expert Comment

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


Regards,
NetPointer
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:kpcapel
Comment Utility
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. :)

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 4,3,0,2
 PRODUCTVERSION 4,3,0,0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "BuildDate", "10/14/2003\0"
            VALUE "Comments", "\0"
            VALUE "CompanyName", "My company\0"
            VALUE "FileDescription", "My DLL\0"
            VALUE "FileVersion", "4.3.0.2\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", "4.3.0.0\0"
            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END
0
 

Author Comment

by:kpcapel
Comment Utility
Anybody got a line on this?  I've increased the points.
0
 
LVL 4

Expert Comment

by:NetPointer
Comment Utility
Hi...

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 .net...now 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.


Regards,
NetPointer
0
 

Author Comment

by:kpcapel
Comment Utility
Interesting.  Let me digest what you've found for a bit.
0
 

Author Comment

by:kpcapel
Comment Utility
NetPointer,

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.
0
 

Author Comment

by:kpcapel
Comment Utility
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 )


0
 
LVL 4

Expert Comment

by:NetPointer
Comment Utility
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.

Regards,
NetPointer
0
 

Accepted Solution

by:
SpazMODic earned 0 total points
Comment Utility
PAQed, with points refunded (500)

SpazMODic
EE Moderator
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now