Blog Home  Home Feed your aggregator (RSS 2.0)  
artiso Blog - Assembly versionen bei Web-Anwendungen ausgeben
Neues rund um's Thema .Net
 
 Friday, May 16, 2008

Für eine ASP.Net Anwendung möchte ich gerne die Versionen meiner Anwendung und aller referenzierten Assemblies ausgeben. Bei Winforms kann ich für die Anwendung mit Application.ProductVersion die Version meiner Anwendung abfragen, die ich in der AssemblyInfo.cs eingestellt habe. Das geht bei ASP.Net nicht. Hier die Lösung, wie man das im Web macht, gleich mit Sortierung:

Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

if (assembly != null)
{
    lblProductVersion.Text = assembly.GetName().Name + " - " + assembly.GetName().Version.ToString();

    var referenceAssemblies = from a in assembly.GetReferencedAssemblies()
            orderby a.Name 
            select a;
    foreach (AssemblyName referenceAssemblyName in referenceAssemblies)
    {
        lblProductVersion.Text += "<br>" + referenceAssemblyName.Name + " - " + referenceAssemblyName.Version;
    }
}

 

Die Ausgabe sieht dann ungefähr so aus:

MyApplication - 1.0.3058.30144
AjaxControlToolkit - 1.0.10618.0
ArtisoAssertLib - 1.0.0.0
CommonComponents - 1.0.3056.28557
CommonContracts - 1.0.3056.28555
CrystalDecisions.CrystalReports.Engine - 11.5.3700.0
CrystalDecisions.ReportSource - 11.5.3700.0
CrystalDecisions.Shared - 11.5.3700.0
cTextBox - 1.0.3058.27781
DataContracts - 1.0.0.0
Infragistics35.WebUI.Misc.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.Shared.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.UltraWebChart.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.UltraWebGrid.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.UltraWebNavigator.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.UltraWebTab.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.UltraWebToolbar.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.WebDataInput.v8.1 - 8.1.20081.1000
Infragistics35.WebUI.WebDateChooser.v8.1 - 8.1.20081.1000
ListValuesComponents - 1.0.3057.30147
ListValuesContracts - 1.0.3057.30146
LoginManagerComponents - 1.0.3033.29632
LoginManagerContracts - 1.0.0.0
mscorlib - 2.0.0.0
NavigationComponents - 1.0.3058.27781
NavigationContracts - 1.0.3058.27780
PCMAreaComponents - 1.0.3058.27781
PCMAreaContracts - 1.0.3058.27779
ProductsAreaComponents - 1.0.3058.27779
ProjectsAreaComponents - 1.0.3058.27780
ProjectsAreaContracts - 1.0.3058.27778
ReportingComponents - 1.0.3058.27781
ReportingContracts - 1.0.3058.27780
SearchComponents - 1.0.3058.27779
SearchContracts - 1.0.3058.27779
System - 2.0.0.0
System.Configuration - 2.0.0.0
System.Core - 3.5.0.0
System.Data - 2.0.0.0
System.Data.DataSetExtensions - 3.5.0.0
System.Data.Linq - 3.5.0.0
System.Drawing - 2.0.0.0
System.Web - 2.0.0.0
System.Web.Extensions - 3.5.0.0
System.Web.Services - 2.0.0.0
System.Xml - 2.0.0.0
TaskListComponent - 1.0.3056.28564
TaskListContract - 1.0.3056.28560
TypesComponents - 1.0.3057.30147
TypesContracts - 1.0.3057.30147
UserManagementContracts - 1.0.0.0
Validators - 1.0.0.0
wwDataBinder - 1.0.2908.21817

Friday, May 16, 2008 4:50:11 PM (Mitteleuropäische Zeit, UTC+01:00)  #    Comments [0]    |   | 
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Copyright © 2008 Thomas. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: