Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Version information in a vb.net dll or exe

Posted on 2003-11-13
16
Medium Priority
?
752 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
16 Comments
 
LVL 4

Expert Comment

by:NetPointer
ID: 9741295
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
ID: 9741388
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
ID: 9742486
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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:kpcapel
ID: 9742708
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
ID: 9742930
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
ID: 9743171
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
ID: 9744298
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
 

Author Comment

by:kpcapel
ID: 9744480
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
ID: 9758666
Anybody got a line on this?  I've increased the points.
0
 
LVL 4

Expert Comment

by:NetPointer
ID: 9765733
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
ID: 9765780
Interesting.  Let me digest what you've found for a bit.
0
 

Author Comment

by:kpcapel
ID: 9778345
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
ID: 9789282
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
ID: 9790905
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
ID: 9828315
PAQed, with points refunded (500)

SpazMODic
EE Moderator
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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