Not sure if this is of interest to anyone. The code snippet was created for one of the exercises we had to endure at a recent scrum focused course … not sure if and when we can start sharing details thereof … will ping the creators and advise.

Anyway, here is the code snippet for those that need to extract the version information from their current (this) assembly:

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Linq;
   4: using System.Text;
   5: using System.Configuration;
   6: using System.Threading;
   7: using System.Reflection;
   8: using System.Net;
   9:  
  10: namespace TailSpin.Version
  11: {
  12:     public class Version_Assembly_Information
  13:     {
  14:         public Version_Assembly_Information() {}
  15:  
  16:         public string Version
  17:         {
  18:             get
  19:             {
  20:                 return Assembly.GetExecutingAssembly().GetName().Version.ToString();
  21:             }
  22:         }
  23:         
  24:         public string Description
  25:         {
  26:             get
  27:             {
  28:                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
  29:                 if (attributes.Length == 0) return "";
  30:                 else                        return ((AssemblyDescriptionAttribute)attributes[0]).Description;
  31:             }
  32:         }
  33:  
  34:         public string Product
  35:         {
  36:             get
  37:             {
  38:                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
  39:                 if (attributes.Length == 0) return "";
  40:                 else                        return ((AssemblyProductAttribute)attributes[0]).Product;
  41:                 }
  42:             }
  43:         }
  44:  
  45:         public string Copyright
  46:         {
  47:             get
  48:             {
  49:                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
  50:                 if (attributes.Length == 0) return "";
  51:                 else                        return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
  52:             }
  53:         }
  54:  
  55:         public string Company
  56:         {
  57:             get
  58:             {
  59:                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
  60:                 if (attributes.Length == 0) return "";
  61:                 else                        return ((AssemblyCompanyAttribute)attributes[0]).Company;
  62:             }
  63:         }
  64:         public string Convenient_Version
  65:         {
  66:             get
  67:             {
  68:                 string Host_Name = System.Net.Dns.GetHostName();
  69:                 string IP_Address = System.Net.Dns.GetHostEntry(Host_Name).AddressList[0].ToString();
  70:                 string Convenient_Version = Description + " " +
  71:                                             Version + " " +
  72:                                             Company + " (" +
  73:                                             Host_Name + " " + 
  74:                                             IP_Address + ")";
  75:                 return Convenient_Version;
  76:             }
  77:         }
  78:     }
  79:  
  80:     public static class Version_Info_Helper
  81:     {
  82:         public static string GetConvenientVersion()
  83:         {
  84:             Version_Assembly_Information ver = new Version_Assembly_Information();
  85:             return ver.Convenient_Version;
  86:         }
  87:     }
  88: }