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;
下面是具体的实现代码。
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"
///
/// AssemblyInfo class.
///
public class AssemblyInfo
{
//Used by functions to access information from Assembly Attributes
///
/// myType.
///
private Type myType;
///
/// Initializes a new instance of the
///
public AssemblyInfo()
{
//Shellform here denotes the actual form.
myType = typeof(ShellForm);
}
///
/// Gets the name of the assembly.
///
///
public String AssemblyName
{
get
{
return myType.Assembly.GetName().Name.ToString();
}
}
///
/// Gets the full name of the assembly.
///
///
public String AssemblyFullName
{
get
{
return myType.Assembly.GetName().FullName.ToString();
}
}
///
/// Gets the code base.
///
///
public String Codebase
{
get
{
return myType.Assembly.Codebase;
}
}
///
/// Gets the copyright.
///
///
public String Copyright
{
get
{
Type att = typeof(AssemblyCopyrightAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyCopyrightAttribute copyattr = (AssemblyCopyrightAttribute)r[0];
return copyattr.Copyright;
}
}
///
/// Gets the company.
///
///
public String Company
{
get
{
Type att = typeof(AssemblyCompanyAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyCompanyAttribute compattr = (AssemblyCompanyAttribute)r[0];
return compattr.Company;
}
}
///
/// Gets the description.
///
///
public String Description
{
get
{
Type att = typeof(AssemblyDescriptionAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyDescriptionAttribute descattr = (AssemblyDescriptionAttribute)r[0];
return descattr.Description;
}
}
///
/// Gets the product.
///
///
public String Product
{
get
{
Type att = typeof(AssemblyProductAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyProductAttribute prodattr = (AssemblyProductAttribute)r[0];
return prodattr.Product;
}
}
///
/// Gets the title.
///
///
public String Title
{
get
{
Type att = typeof(AssemblyTitleAttribute);
object[] r = myType.Assembly.GetCustomAttributes(att, false);
AssemblyTitleAttribute titleattr = (AssemblyTitleAttribute)r[0];
return titleattr.Title;
}
}
///
/// Gets the version.
///
///
public String Version
{
get
{
return myType.Assembly.GetName().Version.ToString();
}
}
}
# endregion



