zoukankan      html  css  js  c++  java
  • How to retrieve AssemblyInfo in C#

    How to retrieve AssemblyInfo in C#

     

    Posted by: Rickie / June. 29, 2006

    The following code snippet shows you how to programmatically retrieve information from AssemblyInfo.cs, e.g. AssemblyProduct, AssemblyVersion, AssemblyCopyright.

     

    Take the following AssemblyInfo.cs as an example:

    [assembly: AssemblyTitle("Enjoy coding experience")]

    [assembly: AssemblyDescription("")]

    [assembly: AssemblyConfiguration("")]

    [assembly: AssemblyCompany("http://rickie.cnblogs.com/")]

    [assembly: AssemblyProduct("your proudct name")]

    [assembly: AssemblyCopyright("Copyright © Rickie 2006")]

    [assembly: AssemblyTrademark("")]

    [assembly: AssemblyCulture("")]

     

    The code snippet in C# is used to retrieve the above information in AssemblyInfo.cs.

     

    Assembly a = Assembly.GetExecutingAssembly();

    txtVersion.Text = a.GetName().Version.ToString();

     

    object[] attrib = a.GetCustomAttributes(typeof(AssemblyProductAttribute), false);

    lblTitle.Text = ((AssemblyProductAttribute)attrib[0]).Product;

    attrib = a.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);

    lblCopyright.Text = ((AssemblyCopyrightAttribute)attrib[0]).Copyright;

    attrib = a.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);

    lblTitleCN.Text = ((AssemblyTitleAttribute)attrib[0]).Title;

     

     

  • 相关阅读:
    shell快捷键
    通过调整tcp参数来防范DDOS攻击
    解决 nf_conntrack: table full, dropping packet 的几种思路
    Linux系统资源限制
    解决Out of socket memory问题
    wrk简介
    部分 TCP 参数简介
    P1706 全排列问题
    P1149 [NOIP2008 提高组] 火柴棒等式
    P1104 生日
  • 原文地址:https://www.cnblogs.com/rickie/p/438622.html
Copyright © 2011-2022 走看看