如何使用AssemblyInfo中的Attribute?

问题:在生成的项目文件中有个文件:Properties ->AssemblyInfo.cs,可以为程序添加一些属性。主要用来设定生成的有关程序集的常规信息dll文件的一些参数,下面是默认的AssemblyInfo.cs文件的内容具体介绍。

 

[assembly: CLSCompliant(true) ]    //是否符合公共语言规范(CLS)
[assembly: ComVisible(false)]         //控制程序集中所有类型对COM的可访问性
//代码的作者和这些代码的的开发人员之间的可靠协定
[assembly: ReliabilityContract(Consistency.WillNotCorruptState,Cer.MayFail)]
 
[assembly: AssemblyTitle(".NET Pet Shop Model")]                                          //标题:
[assembly: AssemblyDescription(".NET Pet Shop Middle-TierComponents")]   //备注:
[assembly: AssemblyConfiguration("")]                                                             //配置文件:
[assembly: AssemblyCompany("Microsoft Corporation")]                                 //公司:
[assembly: AssemblyProduct(".NET Pet Shop4.0")]                                         //产品名称:
[assembly: AssemblyCopyright("Copyright ?2005 MicrosoftCorporation")]    //版权:
[assembly: AssemblyTrademark("")]                                                               //商标声明:
[assembly:AssemblyCulture("")]                                                                   //内部名称

具体解释如下:

1. [assembly: AssemblyTitle("")]
  前面的assembly表示此属性在程序集范围内发生作用。类型名:System.Reflection.AssemblyTitleAttribute

[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyTitleAttribute : Attribute 
此属性描述程序集的名称,如:某某公司某某项目某某模块等,此名称可以是任何合法的字符串,可以有空格。

2. [assembly: AssemblyDescription("")]
类型名:
System.Reflection.AssemblyDescriptionAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyDescriptionAttribute : Attribute
功能:程序集的简单描述,如功能、语言等


3. [assembly: AssemblyDescription("")]
类型名:
System.Reflection.AssemblyDescriptionAttribute
 Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyDescriptionAttribute : Attribute
功能:程序集的简单说明,描述程序集的功能、特性、约束等

 

4. [assembly:AssemblyConfiguration("")]
类型名:
System.Reflection.AssemblyConfigurationAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyConfigurationAttribute : Attribute
功能:程序集的配置信息,如:零售、发布、调试等,.NET运行时没有使用此属性

 

5. [assembly: AssemblyCompany("")]
类型名:
System.Reflection.AssemblyCompanyAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyCompanyAttribute : Attribute
功能:程序集所属的公司名称

 

6. [assembly: AssemblyProduct("")]
类型名:
System.Reflection.AssemblyProductAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyProductAttribute : Attribute
功能:程序集所述的产品名

7. [assembly: AssemblyCopyright("")]
类型名:
System.Reflection.AssemblyCopyrightAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyCopyrightAttribute : Attribute
功能:程序集的版权信息

8. [assembly: AssemblyTrademark("")]
类型名:
System.Reflection.AssemblyTrademarkAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyTrademarkAttribute : Attribute
功能:程序集的商标信息

9. [assembly: AssemblyCulture("")]
类型名:
System.Reflection.AssemblyCultureAttribute
Attribute声明:
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class AssemblyCultureAttribute : Attribute
功能:
枚举的字段表明程序集支持的区域性。程序集也可以指定区域独立性,表明它包含用于默认区域性的资源。运行库将任何区域性属性未设为空的程序集按附属程序集处理。此类程序集受附属程序集绑定规则约束。详细信息,请参见运行库如何定位程序集。

你可能感兴趣的:(attribute)