By default, when you create a new assembly—either a program
or a library—its name is based on the filename, but with the file
extension stripped. This means that our two example projects in this
chapter build assemblies whose filenames are MyProgram.exe and MyLibrary.dll. But as far as the .NET Framework
is concerned, their names are
MyLibrary, respectively, which is
why Example 15-9 just
MyProgram, and not
Actually, that’s not the whole truth. These are the simple names, but there’s more to assembly names. We can ask the .NET Framework to show us the full name of a type’s containing assembly, using the code in Example 15-10.
Example 15-10. Getting a type’s containing assembly’s name
Running this produces the following output:
MyLibrary, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null
As you can see, there are four parts to an assembly name. First there is the simple name, but this is followed by a version number. Assemblies always have a version number. If you don’t specify one, the compiler sets it to 0.0.0.0. But Visual Studio puts an assembly-level attribute in the AssemblyInfo.cs file setting it to 220.127.116.11, which is why we see that in the output. You would typically change the version each time you formally release your code. Example 15-11 shows the (unsurprising) syntax for the version attribute.
Example 15-11. Setting an assembly’s version
[assembly: AssemblyVersion("18.104.22.168")] ...