Getting the real version number of my app?????


J

JP

Ok someone please explain to me why this works in VS 2003 and not VS 2005

I want the C#.NET version number of the DLL that was created for the
specific build of my application. I copied the code from an old C#.NET VS2003
application I wrote years ago.

Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
if (assembly != null)
{
FileVersionInfo verInfo =
FileVersionInfo.GetVersionInfo(assembly.Location);
double majorVersion = verInfo.ProductMajorPart;
double minorVersion = verInfo.ProductMinorPart; ;
int BuildVersion = verInfo.ProductBuildPart;
PageTitle.Text = verInfo.CompanyName + " " + verInfo.ProductName + " (" +
verInfo.ProductVersion.ToString() + ")";
}

In VS2003 this would give me the version number of the DLL in the /bin
folder based on how I had configured the AssemblyInfo.cs. Say for example

[assembly: AssemblyVersion("3.0.*")]

In addtion every build of the VS2003 project would report a new build number
(revision #).


However, in C# VS2005. The version number is always reported as 0.0.0.0. It
appears to be getting the version number from the ASP.NET Temporary cache
folder. I read this has to do with shadowing. All the version numbers for DLL
in the cache are indeed 0.0.0.0
I tried using the following line:

Assembly assembly = System.Reflection.ssembly.Load("App_Code")

And I get a version number, however the build number never changes with each
build. However if I comeback the next day and build again both the minor and
revision numbers do change. I thought these two numbers were based on the
timestamp of the build action. So why do they only change once a day?

I tried putting my AssemblyInfo.cs file in the root of the project but I
cannot do perform an Assembly.Load from the root.

Seems to me this all worked better in VS2003. How in the world do I get the
real version number for my project generated by the Build command in VS 2005.
I have seen some examples that manually alter the assemblyinfo.cs file. But
that seems over complex and unnecessary for info that should be easy to
retrieve
 
Ad

Advertisements

F

Family Tree Mike

JP said:
Ok someone please explain to me why this works in VS 2003 and not VS 2005

I want the C#.NET version number of the DLL that was created for the
specific build of my application. I copied the code from an old C#.NET VS2003
application I wrote years ago.

Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
if (assembly != null)
{
FileVersionInfo verInfo =
FileVersionInfo.GetVersionInfo(assembly.Location);
double majorVersion = verInfo.ProductMajorPart;
double minorVersion = verInfo.ProductMinorPart; ;
int BuildVersion = verInfo.ProductBuildPart;
PageTitle.Text = verInfo.CompanyName + " " + verInfo.ProductName + " (" +
verInfo.ProductVersion.ToString() + ")";
}

In VS2003 this would give me the version number of the DLL in the /bin
folder based on how I had configured the AssemblyInfo.cs. Say for example

[assembly: AssemblyVersion("3.0.*")]

In addtion every build of the VS2003 project would report a new build number
(revision #).


However, in C# VS2005. The version number is always reported as 0.0.0.0. It
appears to be getting the version number from the ASP.NET Temporary cache
folder. I read this has to do with shadowing. All the version numbers for DLL
in the cache are indeed 0.0.0.0
I tried using the following line:

Assembly assembly = System.Reflection.ssembly.Load("App_Code")

And I get a version number, however the build number never changes with each
build. However if I comeback the next day and build again both the minor and
revision numbers do change. I thought these two numbers were based on the
timestamp of the build action. So why do they only change once a day?

I tried putting my AssemblyInfo.cs file in the root of the project but I
cannot do perform an Assembly.Load from the root.

Seems to me this all worked better in VS2003. How in the world do I get the
real version number for my project generated by the Build command in VS 2005.
I have seen some examples that manually alter the assemblyinfo.cs file. But
that seems over complex and unnecessary for info that should be easy to
retrieve

I have used assembly.GetName().Version.ToString(). The file version number
is a very different thing.
 
Ad

Advertisements

J

JP

I understand what your saying, but even if I do not use the file info object.
Say I just flat out refer to the version number directly from the assembly
build:

string Major =
Assembly.GetExecutingAssembly().GetName().Version.Major.ToString();
string Minor =
Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString();
string Revision =
Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString();


All the numbers come back 0 in VS2005 but in VS2003 I get the correct
numbers.
--
JP
..NET Software Developer


Family Tree Mike said:
JP said:
Ok someone please explain to me why this works in VS 2003 and not VS 2005

I want the C#.NET version number of the DLL that was created for the
specific build of my application. I copied the code from an old C#.NET VS2003
application I wrote years ago.

Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
if (assembly != null)
{
FileVersionInfo verInfo =
FileVersionInfo.GetVersionInfo(assembly.Location);
double majorVersion = verInfo.ProductMajorPart;
double minorVersion = verInfo.ProductMinorPart; ;
int BuildVersion = verInfo.ProductBuildPart;
PageTitle.Text = verInfo.CompanyName + " " + verInfo.ProductName + " (" +
verInfo.ProductVersion.ToString() + ")";
}

In VS2003 this would give me the version number of the DLL in the /bin
folder based on how I had configured the AssemblyInfo.cs. Say for example

[assembly: AssemblyVersion("3.0.*")]

In addtion every build of the VS2003 project would report a new build number
(revision #).


However, in C# VS2005. The version number is always reported as 0.0.0.0. It
appears to be getting the version number from the ASP.NET Temporary cache
folder. I read this has to do with shadowing. All the version numbers for DLL
in the cache are indeed 0.0.0.0
I tried using the following line:

Assembly assembly = System.Reflection.ssembly.Load("App_Code")

And I get a version number, however the build number never changes with each
build. However if I comeback the next day and build again both the minor and
revision numbers do change. I thought these two numbers were based on the
timestamp of the build action. So why do they only change once a day?

I tried putting my AssemblyInfo.cs file in the root of the project but I
cannot do perform an Assembly.Load from the root.

Seems to me this all worked better in VS2003. How in the world do I get the
real version number for my project generated by the Build command in VS 2005.
I have seen some examples that manually alter the assemblyinfo.cs file. But
that seems over complex and unnecessary for info that should be easy to
retrieve

I have used assembly.GetName().Version.ToString(). The file version number
is a very different thing.
 

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