Displaying Version information in C# ASP.NET 2.0 and 3.5. - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? .NET, ADO.NET, ASP.NET, AJAX, Atlas, Microsoft AJAX Library, ASP.NET AJAX, and now Windows Azure............follow me on twitter at Wally

Displaying Version information in C# ASP.NET 2.0 and 3.5.

I needed to display the application version in a file based ASP.NET 3.5 application written in Visual Basic.  I wrote the following methods in my AssemblyInfo.vb file in the App_Code directory and it worked! Out popped the Version Number of 0.0.5.0 instead of that annoying 0.0.0.0.  

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

[assembly: AssemblyTitle("blah")]
[assembly: AssemblyCopyright("blah")]
[assembly: AssemblyVersion("0.0.5.0")]
[assembly: AssemblyFileVersion("0.0.5.0")]

/// <summary>
/// Summary description for AssemblyInfo
/// </summary>
public class AssemblyInfo
{
    public AssemblyInfo()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public static string GetVersionNumber()
    {
        return (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
    }
}

Published Jul 15 2008, 06:25 PM by admin
Filed under: ,

Comments

 

steve said:

Hi Wally, I was looking at your code and while the comment says you were writing this in vb.net this sure looks like C# to me - also I dont think you have to put assemblyinfo.vb in the app_code folder in the 3.5 framework

June 1, 2009 4:52 PM
 

wallym said:

I did this for a file based web site.  I would think for a WAP based site, you would continue to do as before in 1.1.

June 4, 2009 10:31 AM
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems