.net 讀取項(xiàng)目AssemblyInfo.cs屬性值
How to use the following info:
AssemblyInfo ainfo = new AssemblyInfo();
frmAbout.Text = ainfo.Title;
frmAbout.menuAbt.Text = string.Format("&About{0}..",ainfo.Title);
frmAbout.Text = "About " + this.Owner.Text;
frmAbout.Icon = this.Owner.Icon;
//You can set the icon like this on the abt form.
frmAbout.pictureBox1.Image = this.Owner.Icon.ToBitmap();
frmAbout.lblTitle.Text = ainfo.Title;
frmAbout.lblVersion.Text = ainfo.Version;
frmAbout.lblCopyright.Text = ainfo.Copyright;
frmAbout.lblDescription.Text = ainfo.Description;
frmAbout.lblCodebase.Text = ainfo.CodeBase;
下面是具體的實(shí)現(xiàn)代碼。
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("Demo Title")]
[assembly: AssemblyDescription("Demo app that reads from the Assembly Info file description")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("World Company")]
[assembly: AssemblyProduct("Not for commercial use.")]
[assembly: AssemblyCopyright("open source (US)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.1.1")]
# region "Class to get the information for AboutForm"
/* This class uses the System.Reflection.Assembly class to access assembly meta-data.
* This class is not a normal feature of AssmblyInfo.cs */
/// <summary>
/// AssemblyInfo class.
/// </summary>
public class AssemblyInfo
{
//Used by functions to access information from Assembly Attributes
/// <summary>
/// myType.
/// </summary>
private Type myType;
/// <summary>
/// Initializes a new instance of the <see cref="AssemblyInfo"/> class.
/// </summary>
public AssemblyInfo()
{
//Shellform here denotes the actual form.
myType = typeof(ShellForm);
}
/// <summary>
/// Gets the name of the assembly.
/// </summary>
/// <value>The name of the assembly.</value>
public String AssemblyName
{
get
{
return myType.Assembly.GetName().Name.ToString();
}
}
/// <summary>
/// Gets the full name of the assembly.
/// </summary>
/// <value>The full name of the assembly.</value>
public String AssemblyFullName
{
get
{
return myType.Assembly.GetName().FullName.ToString();
}
}
/// <summary>
/// Gets the code base.
/// </summary>
/// <value>The code base.</value>
public String CodeBase
{
get
{
return myType.Assembly.CodeBase;
}
}
/// <summary>
/// Gets the copyright.
/// </summary>
/// <value>The copyright.</value>
public String Copyright
{
get
{
Type att = typeof(AssemblyCopyrightAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyCopyrightAttribute copyattr = (AssemblyCopyrightAttribute)r[0];
return copyattr.Copyright;
}
}
/// <summary>
/// Gets the company.
/// </summary>
/// <value>The company.</value>
public String Company
{
get
{
Type att = typeof(AssemblyCompanyAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyCompanyAttribute compattr = (AssemblyCompanyAttribute)r[0];
return compattr.Company;
}
}
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
public String Description
{
get
{
Type att = typeof(AssemblyDescriptionAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyDescriptionAttribute descattr = (AssemblyDescriptionAttribute)r[0];
return descattr.Description;
}
}
/// <summary>
/// Gets the product.
/// </summary>
/// <value>The product.</value>
public String Product
{
get
{
Type att = typeof(AssemblyProductAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyProductAttribute prodattr = (AssemblyProductAttribute)r[0];
return prodattr.Product;
}
}
/// <summary>
/// Gets the title.
/// </summary>
/// <value>The title.</value>
public String Title
{
get
{
Type att = typeof(AssemblyTitleAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyTitleAttribute titleattr = (AssemblyTitleAttribute)r[0];
return titleattr.Title;
}
}
/// <summary>
/// Gets the version.
/// </summary>
/// <value>The version.</value>
public String Version
{
get
{
return myType.Assembly.GetName().Version.ToString();
}
}
}
# endregion
- 使用.NET命令行編譯器編譯項(xiàng)目(如ASP.NET、C#等)
- 創(chuàng)建一個(gè)完整的ASP.NET Web API項(xiàng)目
- iis6偽靜態(tài)重寫(xiě)路徑的配置步驟(.net項(xiàng)目)
- 使用ASP.NET.4.5.1+MVC5.0 搭建一個(gè)包含 Ninject框架 項(xiàng)目
- asp.net 不用組件的URL重寫(xiě)(適用于較大型項(xiàng)目)
- 如何為asp.net網(wǎng)站項(xiàng)目添加子項(xiàng)目
- 關(guān)于有些Asp.net項(xiàng)目發(fā)布后出現(xiàn)網(wǎng)址亂碼的解決方法
- ASP.NET Core新建項(xiàng)目教程(3)
- ASP.NET Core項(xiàng)目結(jié)構(gòu)教程(4)
相關(guān)文章
asp.net簡(jiǎn)化接收參數(shù)值的函數(shù)
獲取querystring 參數(shù)名2008-05-05Asp.net MVC 對(duì)所有用戶輸入的字符串字段做Trim處理的方法
這篇文章主要介紹了Asp.net MVC 如何對(duì)所有用戶輸入的字符串字段做Trim處理,需要的朋友可以參考下2017-06-06詳解ASP.NET Core 在 JSON 文件中配置依賴(lài)注入
本篇文章主要介紹了詳解ASP.NET Core 在 JSON 文件中配置依賴(lài)注入 ,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02asp.net 大文件上傳 之 改版了的SlickUpload.HttpUploadModule(Krystalware
以下代碼中所注釋的部分是所改版的地方。:) Krystalware.SlickUpload.dll2009-05-05ASP.Net中的async+await異步編程的實(shí)現(xiàn)
這篇文章主要介紹了ASP.Net中的async+await異步編程的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08ASP.NET 頁(yè)面之間傳遞值方式優(yōu)缺點(diǎn)比較
URL、Session、Cookies、Server.Transfer、Application和跨頁(yè)面?zhèn)魉汀?/div> 2009-11-11asp.net中button控制先執(zhí)行js再執(zhí)行后臺(tái)程序的方法
這篇文章主要介紹了asp.net中button控制先執(zhí)行js再執(zhí)行后臺(tái)程序的方法,涉及button控件與js的使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-01-01AJAX使用post發(fā)送數(shù)據(jù)xml格式接受數(shù)據(jù)
AJAX使用post發(fā)送數(shù)據(jù)xml格式接受數(shù)據(jù),需要的朋友可以參考一下2013-03-03最新評(píng)論