Strong-named assemblies and AssemblyVersion
Monday, May 17, 2004 05:25 PM
You can create strong-named assemblies in Delphi 8 by setting the AssemblyKeyFile attribute to your key file (created by the sn.exe utility). If you do, however, remember to set the AssemblyVersion attribute. By default, Delphi adds the following attribute to a new assembly (package or library):
This causes the compiler to assign automatic release and build numbers each time the assembly is compiled. The problem here is that if any other assembly references the strong-named assembly, the reference will be broken. Strong-naming is based on being able to uniquely identify an assembly based on four attributes: a file name, a version number, a culture identifier, and a public key token. Unless you explicitly set the AssemblyVersion attribute to a full version number, each compilation would produce a different strong-named assembly. Only change any part of the version number when working on a new version that will actually be deployed.
Note that an assembly can include other version attributes, such as AssemblyFileVersion and AssemblyInformationalVersionAttribute, but those are purely informational and are not used by the CLR.
By the way, Visual Studio .NET has the same problem. The AssemblyInfo.cs created with a new project contains the same incorrect setting for the AssemblyVersion attribute.