获取应用程序集特性值如AssemblyTitle,AssemblyProduct

其他属性值,也可以按类似办法实现如
AssemblyDescription
AssemblyCompany
AssemblyCopyright
AssemblyTrademark
ComVisible
Guid
AssemblyVersion
AssemblyFileVersion

C#代码

//获取程序集的特性方法
public string AssemblyTitle
  {
   get
   {
    object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
    if(attributes.Length > 0)
    {
     AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
     if(titleAttribute.Title != "")
     {
      return titleAttribute.Title;
     }
    }
    return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
   }
  }

vb.net代码

 Public Shared Function getAssemblyTitle() As String
        Dim attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(GetType(AssemblyTitleAttribute), False)
        If attributes.Length > 0 Then
            Dim pTitleAttribute = CType(attributes(0), AssemblyTitleAttribute)
            Return pTitleAttribute.Title
        Else        '如没定义,就默认返回文件名前部份
            Return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase)
        End If
    End Function

    Public Shared Function getAssemblyProduct() As String
        Dim pAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(GetType(AssemblyProductAttribute), False)
        If pAttributes.Length > 0 Then
            Dim pProductAttribute = CType(pAttributes(0), AssemblyProductAttribute)
            Return pProductAttribute.Product
        Else        '如没定义,就默认返回文件名前部份
            Return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase)
        End If
    End Function