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;

     

     

  • 相关阅读:
    1. Change the emulator screen size
    Dynamic Programming for TSP
    框架的概念及用反射技术开发框架的原理
    【PHP 】 伪静态
    【PHP 】伪静态
    框架-Java:Spring MVC
    开源-解决方案-实时数据追踪:Zipkin 介绍
    报表-类型:瀑布图
    报表:目录
    软件-开发软件-Java-Eclipse:百科
  • 原文地址:https://www.cnblogs.com/rickie/p/438622.html
Copyright © 2011-2022 走看看