How to set/read AssemblyVersion in ASP.NET 2.0

G

Guest

How can I set the assembly version in an ASP.NET 2.0 project?

I have added a file AssemblyInfo.cs containing the version number to my
project's App_Code folder. When I try to read the version number from my code
I always get "0.0.0.0".
In ASP.NET 1.1 I was able to read the version of my web application using
the same code.

Thanks for any help,
Martin
 
S

Scott Allen

Where is the code located that reads the assembly version? Is it in
the code file for an ASPX web form? If you post the code I'll give it
a try.
 
G

Guest

Yes, the code is located in a code file, e.g:
protected string VersionInfo
{
get
{
return
System.Reflection.Assembly.GetAssembly(this.GetType()).GetName().Version.ToString();
}
}

The version number is stored in a file AssemblyInfo.cs (which I put into
App_Code):
[assembly: AssemblyVersion("5.0.*")]

It seems this does no longer work, since the web app is not compiled into
one assembly. But I guess there is some way to set and read the version of a
web application.

Thanks for any tips,
Martin Bischoff
 
G

Guest

Thanks for your answer, but it does not help. I'm trying to set and read the
version of a web application (not a class library).

Regards,
Martin Bischoff
 
J

Juan T. Llibre

Indeed, I thought you were trying to read an
assembly's ( class library ) version number.

FWIW, using Reflector on assemblies generated by ASP.NET 2.0
(in the "ASP.NET Temporary Files" directory) yields 0.0.0.0 for
all the applications I have running, including pre-compiled apps.
 
S

Scott Allen

Hey Martin:

I tried:

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

If I use the above in an .aspx code file, I get 0.0.0.0.

If I use the above in a class that I have in a .cs file inside
App_Code, I can get the assembly version that I placed in a .cs file
in App_Code also.

I think this makes sense, given...
It seems this does no longer work, since the web app is not compiled into
one assembly.


.... yeah, that's the tricky part. Around RTM time the ASP.NET should
be releasing a build and deployment project that will have, among
other features, the ability to package all of the assebmlies for a web
app into a single assembly. That should make this easier.
 
B

Bruce Barker

in asp.net 2.0 each page is built into it own assembly, so only the dll the
AssemblyInfo.cs is built into will return the correct answer. just add a
static method to AssemblyInfo.cs that returns the version info, and call
this method from your other pages.

-- bruce (sqlwork.com)
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top