As a developer, I can set version information for an application in the AssemblyInfo.cs file in a .NET application. I like to make the version number visible to someone who doesn't have access to the source or compiled code.
Here are a couple of ways to retrieve this information programmatically in C# using classes from the System.Reflection namespace:
.NET 1.1 ASP.NET Web Project, .NET 1.1 Windows Application, .NET 2.0 Windows Application
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
.NET 2.0 ASP.NET Web Project
string version = System.Reflection.Assembly.Load("AssemblyName").GetName().Version.ToString();
where "AssemblyName" matches the assembly name in the web project's application properties (to open the project properties, right-click your web application, click Properties, click the Application tab, and view or change the Assembly name)
Comments or suggestions? Post below.
Wednesday, January 30, 2008
Subscribe to:
Posts (Atom)