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;

     

     

  • 相关阅读:
    「网络流 24 题」太空飞行计划
    Wannafly挑战赛2D Delete (最短路好题)
    牛客 216 C 小K的疑惑
    Till I Collapse CodeForces
    bzoj 2734 集合悬殊 (状压dp)
    图写成一个类(2)
    写程序的易错点(不定期更新)
    强联通分量之kosaraju算法
    对各种lca算法的理解
    pb_ds的优先队列实现dijkstra
  • 原文地址:https://www.cnblogs.com/rickie/p/438622.html
Copyright © 2011-2022 走看看