0 out of 1 rated this helpful - Rate this topic

AssemblyVersionAttribute Class

Specifies the version of the assembly being attributed.

System.Object
  System.Attribute
    System.Reflection.AssemblyVersionAttribute

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited = false)]
[ComVisibleAttribute(true)]
public sealed class AssemblyVersionAttribute : Attribute

The AssemblyVersionAttribute type exposes the following members.

  Name Description
Public method Supported by the XNA Framework Supported by Portable Class Library AssemblyVersionAttribute Initializes a new instance of the AssemblyVersionAttribute class with the version number of the assembly being attributed.
Top
  Name Description
Public property TypeId When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Public property Supported by the XNA Framework Supported by Portable Class Library Version Gets the version number of the attributed assembly.
Top
  Name Description
Public method Supported by the XNA Framework Supported by Portable Class Library Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected method Supported by the XNA Framework Supported by Portable Class Library Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the XNA Framework Supported by Portable Class Library GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method Supported by the XNA Framework Supported by Portable Class Library GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Supported by the XNA Framework Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected method Supported by the XNA Framework Supported by Portable Class Library MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework Supported by Portable Class Library ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Explicit interface implemetation Private method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetation Private method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetation Private method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetation Private method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top

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). See Assemblies in the Common Language Runtime for more information.

Note 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 note 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 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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Method to Inspect the Assembly Build Date from Version

/// <summary>
/// Gets the assembly build date and time using introspection assuming that the build and revision has been automatically entered.
/// </summary>
/// <example>
/// <code>
/// [assembly: AssemblyVersion("1.0.*")]
/// </code>
/// </example>
/// <remarks>
/// If a null referenced assembly is passed, the callers assembly is used through the <seealso cref="System.Reflection.Assembly.GetCallingAssembly()"/> method.
/// </remarks>
/// <param name="assembly">The assembly to inspect.
/// <returns>The build date for the assembly from the local time of the build machine.</returns>
public static DateTime DateOfBuild(System.Reflection.Assembly assembly)
{
    if (ReferenceEquals(assembly, null))
    {
        assembly = System.Reflection.Assembly.GetCallingAssembly();
    }

    return new DateTime(2000, 1, 1).AddDays(assembly.GetName().Version.Build).AddSeconds(assembly.GetName().Version.Revision * 2);
}
/// <summary>
/// Gets the calling assembly, using the <seealso cref="System.Reflection.Assembly.GetCallingAssembly()"/> method, build date and time using introspection assuming that the build and revision has been automatically entered.
/// </summary>
/// <returns>The build date for the assembly from the local time of the build machine.</returns>
public static DateTime DateOfBuild()
{
    return DateOfBuild(System.Reflection.Assembly.GetCallingAssembly());
}
Method to Inspect the Assembly Build Date from Version

/// <summary>
/// Gets the assembly build date and time using introspection assuming that the build and revision has been automatically entered.
/// </summary>
/// <example>
/// <code>
/// [assembly: AssemblyVersion("1.0.*")]
/// </code>
/// </example>
/// <remarks>
/// If a null referenced assembly is passed, the callers assembly is used through the <seealso cref="System.Reflection.Assembly.GetCallingAssembly()"/> method.
/// </remarks>
/// <param name="assembly">The assembly to inspect.
/// <returns>The build date for the assembly from the local time of the build machine.</returns>
public static DateTime DateOfBuild(System.Reflection.Assembly assembly)
{
    if (ReferenceEquals(assembly, null))
    {
        assembly = System.Reflection.Assembly.GetCallingAssembly();
    }

    return new DateTime(2000, 1, 1).AddDays(assembly.GetName().Version.Build).AddSeconds(assembly.GetName().Version.Revision * 2);
}
/// <summary>
/// Gets the calling assembly, using the <seealso cref="System.Reflection.Assembly.GetCallingAssembly()"/> method, build date and time using introspection assuming that the build and revision has been automatically entered.
/// </summary>
/// <returns>The build date for the assembly from the local time of the build machine.</returns>
public static DateTime DateOfBuild()
{
    return DateOfBuild(System.Reflection.Assembly.GetCallingAssembly());
}
Revision number
Although the default revision number is stated as "random" in practice it isn't. It is the number of seconds since 12 am divided by 2.