You specify assembly-level attributes by using the following syntax:
<Assembly: Attribute1, Assembly: Attribute2..., Assembly: AttributeN>
You specify module-level attributes by using similar syntax:
<Module: Attribute1, Module: Attribute2..., Module: AttributeN>
You add global attributes in source code after any top-level directives, such as Option Explicit and Imports statements, but before any type or namespace declarations. Global attributes can appear in multiple source files in a project, but they are generally put in the file AssemblyInfo.vb file created automatically with Visual Basic projects.
Assembly attributes are values that provide information about an assembly. They fall into the following categories:
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, based on the file that contains the assembly manifest. The AssemblyFlagsAttribute attribute specifies whether multiple copies of the assembly can coexist.
The following table shows the identity attributes.
The following code applies the version and culture attributes to an assembly:
'Set version number for assembly.
<Assembly: Reflection.AssemblyVersionAttribute("4.3.2.1")>
'Set culture as German.
<Assembly: Reflection.AssemblyCultureAttribute("de")>
Informational Attributes
You can 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. This includes title, description, default alias, and configuration. The following table shows the assembly manifest attributes defined in the System.Reflection namespace.
Strong Name Attributes
Strong names are unique identifiers that protect the identity and integrity of an assembly. You can sign an assembly from the Visual Studio IDE through the Signing Page, Project Designer. For more information, see Managing Assembly and Manifest Signing.
Alternatively, you can use strong-name attributes to set a strong name for an assembly. The following table shows the strong-name attributes defined in the System.Reflection namespace.
Attribute
|
Purpose
|
|---|
AssemblyDelaySignAttribute
|
Boolean that indicates whether you want to reserve space in the executable file for the strong-name signature, but defer the actual signing until some later stage. For more information, see Delay Signing an Assembly.
|
AssemblyKeyFileAttribute
|
Indicates the file that contains a key. The location of the KeyFile should be relative to the project output directory, which is %Project Directory%\obj\<configuration>. For example, if your KeyFile is located in the project directory, you would specify the AssemblyKeyFile attribute as
[assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
AssemblyKeyNameAttribute
|
Refers to a key that has been installed in the Crypto Service Provider (CSP) on your computer. You must specify a key in order for the file to be signed.
|
If the KeyFile and the KeyName values are both specified, the following processing occurs:
If the KeyName can be found in the CSP, that key is used.
If the KeyName does not exist and the KeyFile does exist, the key in the KeyFile is installed into the CSP and used.
For more information, see Assembly Security Considerations.