Setting Assembly Attributes
Assembly attributes are values that provide information about an assembly. The attributes are divided into the following sets of information:
- Assembly identity attributes.
- Informational attributes.
- Assembly manifest attributes.
- Strong name attributes.
Assembly Identity Attributes
Three attributes, together with a strong name (if applicable), determine the identity of an assembly: name, version, and culture. These attributes form the full name of the assembly and are required when referencing the assembly in code. You can use attributes to set an assembly's version and culture. The compiler or the Assembly Linker (Al.exe) sets the name value when the assembly is created, based on the file containing the assembly manifest.
The following table describes the version and culture attributes.
|Assembly identity attribute||Description|
|AssemblyCultureAttribute||Enumerated field indicating the culture that the assembly supports. An assembly can also specify culture independence, indicating that it contains the resources for the default culture.
|AssemblyFlagsAttribute||Value that sets assembly attributes, such as whether the assembly can be run side by side.|
|Numeric value in the format major.minor.build.revision. For example, 188.8.131.52. The common language runtime uses this value to perform binding operations in strong-named assemblies.|
The following code example shows how to apply the version and culture attributes to an assembly.
'Set version number for the assembly. <Assembly:AssemblyVersionAttribute("184.108.40.206")> 'Set culture as German. <Assembly:AssemblyCultureAttribute("de")> [C#] //Set version number for the assembly. [assembly:AssemblyVersionAttribute("220.127.116.11")] //Set culture as German. [assembly:AssemblyCultureAttribute("de")]
You can use informational attributes to provide additional company or product information for an assembly. The following table describes the informational attributes you can apply to an assembly.
|AssemblyCompanyAttribute||String value specifying a company name.|
|AssemblyCopyrightAttribute||String value specifying copyright information.|
|AssemblyFileVersionAttribute||String value specifying the Win32 file version number. This normally defaults to the assembly version.|
|AssemblyInformationalVersionAttribute||String value specifying version information that is not used by the runtime, such as a full product version number.|
|AssemblyProductAttribute||String value specifying product information.|
|AssemblyTrademarkAttribute||String value specifying trademark information.|
These attributes can appear on the Windows Properties page of the assembly, or they can be overridden using the /win32res compiler option to specify your own Win32 resource file.
Assembly Manifest Attributes
You can use assembly manifest attributes to provide information in the assembly manifest, including title, description, the default alias, and configuration. The following table describes the assembly manifest attributes.
|Assembly manifest attribute||Description|
|AssemblyConfigurationAttribute||String value indicating the configuration of the assembly, such as Retail or Debug. The runtime does not use this value.|
|AssemblyDefaultAliasAttribute||String value specifying a default alias to be used by referencing assemblies. This value provides a friendly name when the name of the assembly itself is not friendly (such as a GUID value). This value can also be used as a short form of the full assembly name.|
|AssemblyDescriptionAttribute||String value specifying a short description that summarizes the nature and purpose of the assembly.|
|AssemblyTitleAttribute||String value specifying a friendly name for the assembly. For example, an assembly named comdlg might have the title Microsoft Common Dialog Control.|
Strong Name Attributes
You can use strong name attributes to set a strong name for an assembly. The following table describes the strong name attributes.
|Strong name attributes||Description|
|AssemblyDelaySignAttribute||Boolean value indicating that delay signing is being used.|
|AssemblyKeyFileAttribute||String value indicating the name of the file that contains either the public key (if using delay signing) or both the public and private keys passed as a parameter to the constructor of this attribute. Note that the file name is relative to the output file path (the .exe or .dll), not the source file path.|
|AssemblyKeyNameAttribute||Indicates the key container that contains the key pair passed as a parameter to the constructor of this attribute.|
The following code example shows the attributes to apply when using delay signing to create a strong-named assembly with a public key file called
<Assembly:AssemblyKeyFileAttribute("myKey.snk")> <Assembly:AssemblyDelaySignAttribute(True)> [C#] [assembly:AssemblyKeyFileAttribute(@"..\..\myKey.snk")] [assembly:AssemblyDelaySignAttribute(true)]