Share via


AssemblyVersionAttribute Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Specifies the version of the assembly being attributed.

Inheritance Hierarchy

System. . :: . .Object
  System. . :: . .Attribute
    System.Reflection..::..AssemblyVersionAttribute

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple := False)> _
Public NotInheritable Class AssemblyVersionAttribute _
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class AssemblyVersionAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Assembly, AllowMultiple = false)]
public ref class AssemblyVersionAttribute sealed : public Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = false)>]
type AssemblyVersionAttribute =  
    class
        inherit Attribute
    end
public final class AssemblyVersionAttribute extends Attribute

The AssemblyVersionAttribute type exposes the following members.

Constructors

  Name Description
Public method AssemblyVersionAttribute Initializes a new instance of the AssemblyVersionAttribute class with the version number of the assembly being attributed.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

The assembly version number is part of an assembly's identity and plays a key part in binding to the assembly and in version policy. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file).

Note

Version checking only occurs with strong-named assemblies.

The version number has four parts, as follows:

<major version>.<minor version>.<build number>.<revision>

Important

All components of the version must be integers greater than or equal to 0. Metadata restricts the major, minor, build, and revision components for an assembly to a maximum value of UInt16..::..MaxValue - 1. If a component exceeds this value, a compilation error occurs.

You can specify all the values or you can accept the default build number, revision number, or both by using an asterisk (*). For example, [assembly:AssemblyVersion("2.3.25.1")] indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number. A version number such as [assembly:AssemblyVersion("1.2.*")] specifies 1 as the major version, 2 as the minor version, and accepts the default build and revision numbers. A version number such as [assembly:AssemblyVersion("1.2.15.*")] specifies 1 as the major version, 2 as the minor version, 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is random.

Note

If you specify an asterisk for the build number, you cannot specify a revision number.

The assembly major and minor versions are used as the type library version number when the assembly is exported. Some COM hosts do not accept type libraries with the version number 0.0. Therefore, if you want to expose an assembly to COM clients, set the assembly version explicitly to 1.0 in the AssemblyVersionAttribute page for projects created outside Visual Studio 2005 and with no AssemblyVersionAttribute specified. Do this even when the assembly version is 0.0. All projects created in Visual Studio 2005 have a default assembly version of 1.0.*.

To get the name of an assembly you have loaded, call GetName on the assembly to get an AssemblyName, and then get the Version property. To get the name of an assembly you have not loaded, call GetAssemblyName from your client application to check the assembly version that your application uses.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Reflection Namespace