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;

     

     

  • 相关阅读:
    XP显示桌面
    批量改名
    poj 3126 BFS
    poj 3278 BFS
    poj 1426 BFS
    准备打酱油…
    POJ 2243 BFS 和 简单的调试方法学习
    K
    EXCEL fundamentals
    poj 1011 DFS+剪枝
  • 原文地址:https://www.cnblogs.com/rickie/p/438622.html
Copyright © 2011-2022 走看看