Assembly attributes are values that provide information about an assembly. They're usually set in an AssemblyInfo.cs file. The attributes are divided into the following sets of information:
Assembly identity attributes
Informational attributes
Assembly manifest attributes
Strong name attributes
This article is scoped to adding assembly attributes from code. For information on adding assembly attributes to projects (not in code), see Set assembly attributes in a project file.
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.
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. Note: The runtime treats any assembly that does not have the culture attribute set to null as a satellite assembly. Such assemblies are subject to satellite assembly binding rules. For more information, see How the runtime locates 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("4.3.2.1")];
// Set culture as German.
[assembly:AssemblyCultureAttribute("de")];
// Set version number for the assembly.
[assembly:AssemblyVersionAttribute("4.3.2.1")]
// Set culture as German.
[assembly:AssemblyCultureAttribute("de")]
' Set version number for the assembly.
<Assembly:AssemblyVersionAttribute("4.3.2.1")>
' Set culture as German.
<Assembly:AssemblyCultureAttribute("de")>
Informational attributes
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.
String value specifying version information that is not used by the common language runtime, such as a full product version number. Note: If this attribute is applied to an assembly, the string it specifies can be obtained at run time by using the Application.ProductVersion property. The string is also used in the path and registry key provided by the Application.UserAppDataPath and Application.UserAppDataRegistry properties.
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 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.
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.
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.
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 myKey.snk.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Microsoft Graph Toolkit components are flexible for customization. You can change the behavior of components by using attributes. You can also customize component styling by using CSS custom properties to match your app's branding.