CA1016: Mark assemblies with AssemblyVersionAttribute

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here

TypeName MarkAssembliesWithAssemblyVersion
CheckId CA1016
Category Microsoft.Design
Breaking Change Non-breaking

Cause

The assembly does not have a version number.

Rule Description

The identity of an assembly is composed of the following information:

  • Assembly name

  • Version number

  • Culture

  • Public key (for strongly named assemblies).

    The .NET Framework uses the version number to uniquely identify an assembly, and to bind to types in strongly named assemblies. The version number is used together with version and publisher policy. By default, applications run only with the assembly version with which they were built.

How to Fix Violations

To fix a violation of this rule, add a version number to the assembly by using the System.Reflection.AssemblyVersionAttribute attribute. See the following example.

When to Suppress Warnings

Do not suppress a warning from this rule for assemblies that are used by third parties, or in a production environment.

Example

The following example shows an assembly that has the AssemblyVersionAttribute attribute applied.

using namespace System;
using namespace System::Reflection;

[assembly: AssemblyVersionAttribute("4.3.2.1")];
namespace DesignLibrary {}
using System;
using System.Reflection;

[assembly: AssemblyVersionAttribute("4.3.2.1")]
namespace DesignLibrary {}
Imports System
Imports System.Reflection

<Assembly: AssemblyVersionAttribute("4.3.2.1")>
Namespace DesignLibrary
End Namespace

See Also

Assembly Versioning How to: Create a Publisher Policy