471,316 Members | 1,002 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to set/read AssemblyVersion in ASP.NET 2.0

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
Nov 19 '05 #1
7 6022
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 10 Oct 2005 05:56:06 -0700, Martin Bischoff
<ni******@newsgroup.nospam> wrote:
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


Nov 19 '05 #2
When you open the assembly with Reflector
( http://www.aisto.com/roeder/dotnet/ )
doesn't it show the assembly's version number ?

It does for my assemblies, and I don't do anything special to set them.

In any case, read : http://www.devx.com/codemag/Article/28747/0/page/3
if you want to set a specific assembly version number.

Take a look at the dialogue in Figure 3.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Martin Bischoff" <ni******@newsgroup.nospam> wrote in message
news:3D**********************************@microsof t.com...
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

Nov 19 '05 #3
Yes, the code is located in a code file, e.g:
protected string VersionInfo
{
get
{
return
System.Reflection.Assembly.GetAssembly(this.GetTyp e()).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

"Scott Allen" wrote:
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/


Nov 19 '05 #4
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

"Juan T. Llibre" wrote:
When you open the assembly with Reflector
( http://www.aisto.com/roeder/dotnet/ )
doesn't it show the assembly's version number ?

It does for my assemblies, and I don't do anything special to set them.

In any case, read : http://www.devx.com/codemag/Article/28747/0/page/3
if you want to set a specific assembly version number.

Take a look at the dialogue in Figure 3.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Martin Bischoff" <ni******@newsgroup.nospam> wrote in message
news:3D**********************************@microsof t.com...
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


Nov 19 '05 #5
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.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Martin Bischoff" <ni******@newsgroup.nospam> wrote in message
news:6C**********************************@microsof t.com...
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

"Juan T. Llibre" wrote:
When you open the assembly with Reflector
( http://www.aisto.com/roeder/dotnet/ )
doesn't it show the assembly's version number ?

It does for my assemblies, and I don't do anything special to set them.

In any case, read : http://www.devx.com/codemag/Article/28747/0/page/3
if you want to set a specific assembly version number.

Take a look at the dialogue in Figure 3.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Martin Bischoff" <ni******@newsgroup.nospam> wrote in message
news:3D**********************************@microsof t.com...
> 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


Nov 19 '05 #6
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #7
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)

"Martin Bischoff" <ni******@newsgroup.nospam> wrote in message
news:3D**********************************@microsof t.com...
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

Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mark | last post: by
2 posts views Thread by Mark | last post: by
4 posts views Thread by Matthew Smith | last post: by
5 posts views Thread by c8prog | last post: by
7 posts views Thread by Michael Maes | last post: by
3 posts views Thread by AnthonyWJones | last post: by
3 posts views Thread by MattB | last post: by
reply views Thread by rosydwin | last post: by

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.