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);
   }
  }

posted @ 2013-04-11 19:18  Predator  阅读(366)  评论(0编辑  收藏  举报