How to get the exact Assembly Version

Y

Yoavo

Hi,
I need to get the exact AssemblyVersion.
I tried to use something like:

string appName =
System.Reflection.Assembly.GetAssembly(this.GetType()).Location;
System.Reflection.AssemblyName assemblyName =
System.Reflection.AssemblyName.GetAssemblyName(appName);
return assemblyName.Version.ToString();

The problem with this code is that for 2 different versions such as:
"1.0001.0001.0076"
and
"1.1000.0001.0076"

I will get the same result:
"1.1.1.76"

Is it possible to get the "full" version string ?

thanks,
Yoav.
 
M

Marc Gravell

The problem with this code is that for 2 different versions such as:
"1.0001.0001.0076"
and
"1.1000.0001.0076"

Really? It might strip *leading* zeros, but the second appears as
"1.1000.1.76" for me.

Unfortunately, AssemblyVersionAttribute is removed from the generated
assembly, so you can't use Attribute.GetCustomAttribute() to get the
original text; I suspect you probably have to accept the way it
behaves. Sorry...

Marc
 
D

Duggi

Hi,
I need to get the exact AssemblyVersion.
I tried to use something like:

string appName =
System.Reflection.Assembly.GetAssembly(this.GetType()).Location;
System.Reflection.AssemblyName assemblyName =
System.Reflection.AssemblyName.GetAssemblyName(appName);
return assemblyName.Version.ToString();

The problem with this code is that for 2 different versions such as:
"1.0001.0001.0076"
and
"1.1000.0001.0076"

I will get the same result:
"1.1.1.76"

Is it possible to get the "full" version string ?

thanks,
Yoav.

Hi Yoav,

I was just trying to understand what is the difference between

Version 1.1.1.76 which spells MajorVersion 1, MajorRevision
1, MinorVesion 1, MinorRevision 76
Version 1.0001.0001.0076 which spells MajorVersion 1, MajorRevision
1, MinorVesion 1, MinorRevision 76

I think both are one and the same... How many zeros you add before a
number does not really effect the semantics.

The problem with this code is that for 2 different versions such as:
"1.0001.0001.0076"
and
"1.1000.0001.0076"

I will get the same result:
"1.1.1.76"

for the second case you are supposed to get 1.1000.1.76. I suggest you
check out the assembly version

-Cnu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top