Assembly level attributes interpreted by the C# compiler
-
Article
-
-
Most attributes are applied to specific language elements such as classes or methods; however, some attributes are global?they apply to an entire assembly or module. For example, the
AssemblyVersionAttribute
attribute can be used to embed version information into an assembly, like this:
[assembly: AssemblyVersion("1.0.0.0")]
Global attributes appear in the source code after any top level
using
directives and before any type, module, or namespace declarations. Global attributes can appear in multiple source files, but the files must be compiled in a single compilation pass. Visual Studio adds global attributes to the AssemblyInfo.cs file in .NET Framework projects. These attributes aren't added to .NET Core projects.
Assembly attributes are values that provide information about an assembly. They fall into the following categories:
- Assembly identity attributes
- Informational attributes
- Assembly manifest attributes
Assembly identity attributes
Three attributes (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 you reference it in code. You can set an assembly's version and culture using attributes. However, the name value is set by the compiler, the Visual Studio IDE in the
Assembly Information Dialog Box
, or the Assembly Linker (Al.exe) when the assembly is created. The assembly name is based on the assembly manifest. The
AssemblyFlagsAttribute
attribute specifies whether multiple copies of the assembly can coexist.
The following table shows the identity attributes.
You use informational attributes to provide additional company or product information for an assembly. The following table shows the informational attributes defined in the
System.Reflection
namespace.
Assembly manifest attributes
You can use assembly manifest attributes to provide information in the assembly manifest. The attributes include title, description, default alias, and configuration. The following table shows the assembly manifest attributes defined in the
System.Reflection
namespace.