AssemblyInfo
A AssemblyInfo.cs file is automatically generated under the Properties folder for. NET project, and the file contains information and items, right-click Property->application->assembly Information exactly the same. Its purpose is to define different properties for the assembly. All properties are based on System.Attribute in the. NET framework. Its syntax is as follows:
[assembly:<attribute> (<setting>)]
AssemblyVersionAttribute
The file version number is set, where attribute can be omitted:
[Assembly:assemblyversion ("1.0")]
Property |
Describe |
Assemblytitle |
Assembly title, default to DLL library name |
Assemblydescription |
A brief description of the assembly |
Assemblycompany |
Name of the company to which the assembly belongs |
Assemblyproduct |
Product name based on this Assembly |
Assemblycopyright |
Assembly-owned Copyright |
Assemblytrademark |
Legal trademarks |
AssemblyVersion |
Version of the Assembly |
Assemblyculture |
Culture supported by the Assembly |
Assemblyconfiguration |
Specify a build configuration for a program, such as a publish or debug configuration |
ComVisible |
The accessibility of all types to COM in a control set |
These properties basically allow a string to define the value of the property, AssemblyVersion exception, and must use a string in a specific format: Major.Minor.Build.Revision
Major and minor are the main, the minor version number, the change of the version number usually indicates that there are incompatible changes with the previous version. For example, the 2.1 version and the 2.2 version based on the same library have incompatible places.
The build number (build) is a different compilation setting for the same sub-version of an assembly. It may occasionally appear incompatible, but usually, as in the case of 2.1.17 and 2.1.42, the operation is the same.
The revision number (Revision) is used for fixed-line bugs or other occasional updates, and it usually does not break compatibility.
Get this information in the program
Original code (http://blog.sina.com.cn/s/blog_61c4c1f60100eira.html)
Public classGetassembly<t> { PrivateType MyType; Publicgetassembly (Type myType) { This. MyType =typeof(T); } Public stringAssemblyName {Get{returnMyType.Assembly.GetName (). Name.tostring (); } } Public stringAssemblyFullName {Get{returnMyType.Assembly.GetName (). Fullname.tostring (); } } PublicString CodeBase {Get { returnmyType.Assembly.CodeBase; } } PublicString Version {Get { returnMyType.Assembly.GetName (). Version.tostring (); } } PublicString Copyright {Get{Type att=typeof(AssemblyCopyrightAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyCopyrightAttribute copyattr= (AssemblyCopyrightAttribute) r[0]; returncopyattr. Copyright; } } PublicString Company {Get{Type att=typeof(AssemblyCompanyAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyCompanyAttribute compattr= (AssemblyCompanyAttribute) r[0]; returnCompattr.company; } } PublicString configration {Get{Type att=typeof(AssemblyConfigurationAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyConfigurationAttribute configattr= (AssemblyConfigurationAttribute) r[0]; returnconfigattr. Configuration; } } Public stringTrademark {Get{Type att=typeof(AssemblyTrademarkAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyTrademarkAttribute AA= (AssemblyTrademarkAttribute) r[0]; returnAA. Trademark; } } Public stringCulture {Get{Type att=typeof(AssemblyCultureAttribute); Object[] a = MyType.Assembly.GetCustomAttributes (Att,false); if(A.length >0) {assemblycultureattribute AA= (AssemblyCultureAttribute) a[0]; returnAA. Culture; } Else { return "No Value"; } } } PublicString Description {Get{Type att=typeof(AssemblyDescriptionAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyDescriptionAttribute descattr= (AssemblyDescriptionAttribute) r[0]; returndescattr. Description; } } PublicString Product {Get{Type att=typeof(AssemblyProductAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyProductAttribute prodattr= (AssemblyProductAttribute) r[0]; returnprodattr. Product; } } PublicString Title {Get{Type att=typeof(AssemblyTitleAttribute); Object[] r = MyType.Assembly.GetCustomAttributes (ATT,false); AssemblyTitleAttribute titleattr= (AssemblyTitleAttribute) r[0]; returntitleattr. Title; } }}
C # (Visual Studio) AssemblyInfo