Working with Display NamesFigure 12.5 shows an example of a display name . Display names are strings that can be used to identify assemblies. They have four parts . Figure 12.5 This is also known as a fully qualified display name as you will learn later in the chapter. Notice that it has four parts, separated by commas.SoapSudsCode, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a The first part is the name of the DLL or EXE minus the extension. So if the DLL is named ChildCare.DLL, the first part of the display name is ChildCare. The second part is the version number. The version number is a string in the form "version=1.2.3.4." Version numbers in .NET have four elements: major, minor, build, and revision. Major and minor numbers are the ones that people normally use to refer to a software version, "Tools version 1.5," for example. Build numbers and revision numbers are normally used for internal purposes. When a company is working on the next version of their software, they might refer to the version as 1.5, but every time someone fixes a major bug, they rebuild the code and assign a different build number to the latest code. In this way when the boss comes around and says, "I thought you were going to fix that major bug we had," you can say, "Oh, it should be there in the latest build. Do you have build number 245?" The last number is for when you have to build multiple times on the same day, or when something minor is changed and you don't really want to do a full build of all the source code. The rule of thumb is that if you change major functionality in the software you should change at least the major or the minor numbers. The other two numbers can be used at your discretion. The third part of the display name is the culture. The culture is written in the form "Culture=en_us" or "Culture=neutral". Cultures have two parts, the language, and the region in which the language is spoken. They're used in situations in which programs need to be translated into different languages. Any assembly that contains executable code has a Culture=neutral, which means it can be used from anywhere . You can also put resources into an assembly without code, like a list of strings, and then assign it a culture. Writing assemblies for resources is beyond the scope of this book; for the most part you will leave the culture as neutral. The third part of the display name is the PublicKeyToken, which is written in the form "PublicKeyToken= a5d015c7d5a0b012." The last number is a part of the public key in a public/private encryption key. With public/private key encryption, a private key is used to encrypt information, while the public key is used to decrypt it. Only information encrypted with the private key can be decrypted with the public key. In Chapter 13, "C# Web projects," you'll learn how to add public key tokens to an assembly. You add a public key token for two purposes: one is to prevent "bad guys" (or bad people, rather) from tampering with the assembly. The second reason is that you need to add a public key if you want to share your assembly with multiple Web applications. Many times display names are used to refer to assemblies that are in the Global Assembly Cache (GAC). The GAC has assemblies that are shared by multiple applications. In Chapter 13 you'll learn how to add an assembly to the GAC. For now, let's see how to obtain the display name of an assembly that is in the GAC. To build the display name for an assembly in the GAC:
Tips
|