Export (0) Print
Expand All

Global Attributes

Most attributes are attached to specific language elements, such as classes or methods; however, some attributes are global — they apply to an entire assembly or module. Assembly-level attributes are specified as follows:

[assembly: attribute-list]

Module-level attributes are specified as follows:

[module: attribute-list]

where:

attribute-list
A list of applicable global attributes.

Global attributes appear in the source code after any top-level using directives and before any type or namespace declarations. Global attributes can appear in multiple source files in a single compilation.

Of the .NET Framework assembly-level attributes, the following let you modify the information in an assembly:

Use the file created by Strong Name Utility (SN.exe) as the parameter to AssemblyKeyFileAttribute, AssemblyKeyNameAttribute, or AssemblyDelaySignAttribute to sign (or give a strong name to) your assembly.

See the file AssemblyInfo.cs, which is added to all C# projects created in Visual Studio, to see those attributes in use.

Use /target:module to create an output file that does not contain an Assembly.

Note   Assembly-level attributes are ignored if you are not creating an assembly.

Example

The CLSCompliant attribute indicates whether all types defined in the assembly comply with the .NET Framework common language specification.

[assembly: System.CLSCompliant(true)]

See Also

Introduction to Attributes | Using Attributes | Attribute Targets | Creating Custom Attributes | Retrieving Attribute Information

Show:
© 2014 Microsoft