C # (Visual Studio) AssemblyInfo

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.