473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

AssemblyVersionAttribute

Hi,

I could not get the AssemblyVersion attribute. I use the following code:

public static string GetProductVersion()

{

Assembly appAssembly = Assembly.GetExecutingAssembly();

Object[] cma;

cma = appAssembly.GetCustomAttributes( typeof(AssemblyVersionAttribute) ,
true );

return( ((AssemblyVersionAttribute)(cma[0])).InformationalVersion );

}

The same kind of code works with other attributes (AssemblyTitle,
AssemblyProduct,...). Someone can help?

thanks in advance,
Pascal
Nov 22 '05 #1
3 11553
If you are just looking for Assembly Version number, you can get it
using this code snippet..

Assembly.GetExecutingAssembly().GetName().Version. ToString()

Cheers,

Adam Cooper
-------------------------------------------------------------------------------------------
J-Integra Interoperability Solutions
http://j-integra.intrinsyc.com/
high performance interop middleware for java, corba, com & .net

Nov 22 '05 #2
thank you,

this is exactly what i need
Pascal
"Adam Cooper" <ad*********@gmail.com> a écrit dans le message de news:
11**********************@g49g2000cwa.googlegroups. com...
If you are just looking for Assembly Version number, you can get it
using this code snippet..

Assembly.GetExecutingAssembly().GetName().Version. ToString()

Cheers,

Adam Cooper
-------------------------------------------------------------------------------------------
J-Integra Interoperability Solutions
http://j-integra.intrinsyc.com/
high performance interop middleware for java, corba, com & .net

Nov 23 '05 #3
Pascal Cloup wrote:
I could not get the AssemblyVersion attribute. I use the following
code: cma = appAssembly.GetCustomAttributes(
typeof(AssemblyVersionAttribute) , true );


The assembly version is NOT a custom attribute. Unfortunately, the C#
syntax confuses the issue. [AssemblyVersion] is a message to the
compiler to tell the compiler to set the version metadata of the
assembly to the specified value. As Adam pointed out, you get the
version through the name of the assembly, not through a custom
attribute.

C# is quite sloppy in this respect. For example [AssemblyKeyFile] is a
message to the compiler to use a specific key file to sign the assembly
and create the public key token for the strong name. The path and name
of the key file is of no use at all to the runtime, nor to anyone else,
but the C# compiler will add a custom attribute (.custom metadata) for
the key file in your assembly! This is totally unnecessary and it leaks
possibly personal information (do you want your customers to know the
name of your build folder?). In .NET 2.0 the C# compiler allows you to
use a command line switch to pass the name of the key file and so the
..custom attribute is not created. (However, code that uses
[AssemblyKeyFile] will still create the .custom metadata on .NET 2.0.)

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: | last post by:
Hi, In the AssemblyInfo.cs file I change the AssemblyVersion; attribute from the default "1.0.*" blah I notice that its FORCING 4 digit notation, so if I use "1.0.0" I get "1.0.0.0" in that...
7
by: Zdenko | last post by:
Hi all, I have following line in AssemblyInfo.cpp file: ; When I build managed application, FileVersion column in Windows explorer is empty. When I build C# dll, it is displayed correctly.
0
by: Siew Fai | last post by:
hi All, In the documentation ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemReflect ionAssemblyVersionAttributeClassTopic.htm there is a sentence "A version number such as...
4
by: Phil Galey | last post by:
I created an About box and am able to get all the assembly information from the program to show up in the About box except the Version. I created the About box as a separate Windows application,...
2
by: Eddie | last post by:
I tried a few more thing. I found that I can access the AssemblyInfo.cpp like follows.(This is from the VS help system.) Type^ clsType = Form1::typeid; Assembly^ assy = clsType->Assembly; ...
0
by: sovarschizsuzsa | last post by:
Hy everybody! I would like to set the AssemblyVersionAttribute fourth part from a given parameter. My project is compiled with a makefile, so this parameter becomes value through this makefile....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.