Setting version information

You can set assembly version information using an attribute called AssemblyVersion. The AssemblyVersion attribute takes a string describing the version number for the assembly, which is a series of four integers. The first integer is the major version number; the second integer is the minor version number; the third integer is the build number; and the fourth integer is the revision number. You can specify all four numbers for an assembly using the AssemblyVersion attribute:

[assembly: AssemblyVersion("1.0.0.0")]

As a shortcut, the C# compiler generates a revision number automatically if an asterisk is used instead of a revision number:

[assembly: AssemblyVersion("1.0.0.*")]

This syntax instructs the C# compiler to assign a revision number of its choosing to the assembly. The C# compiler calculates the number of seconds between midnight and the time you are compiling your code, divides the number by two, and uses the remainder from that division that number as the basis for generating a unique revision number. (This is called a modulo 2 operation, as a modulo operation computes the remainder of the division between two operands.) This enables a unique version number to be generated for every build.

As a further shortcut, the C# compiler generates a build number and a revision number automatically if an asterisk is used as the build number:

[assembly: AssemblyVersion("1.0.*")]

This syntax instructs the C# compiler to assign a build number and a revision number of its choosing to the assembly. In addition to the automatic revision number calculation already described, the C# compiler also calculates a build number using the number of days between January 1, 2000 and the day the code is compiled.

0 0

Post a comment