O'Reilly logo

Object-Oriented Programming with Visual Basic .NET by J.P. Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.8. The Global Assembly Cache

If you use an object from the .NET class library in your own code, you have to reference the assembly in which it is defined at compile time. For instance, if you want to use the MessageBox class in one of your applications, you need to make sure that the System.Windows.Forms assembly is made available to the compiler. This assembly contains the System.Windows.Forms namespace, which in turn contains the MessageBox class. The command-line statement needed to compile your source code is:

vbc /t:winexe /r:System.Windows.Forms.dll mycode.vb

Referencing one of your own assemblies is no different, but a full path to the assembly is expected. For example:

vbc /t:library /r:<path>\mylib.dll mycode.vb

A path is not necessary for System.Windows.Forms.dll because like all .NET class library assemblies, it lives in the global assembly cache (GAC). The GAC is a directory, shown in Figure 2-5, that contains assemblies that are meant to be shared by several applications on a single machine. The actual path to the GAC is <%windir%>/assembly.

Figure 2-5. The GAC in an Explorer list pane

2.8.1. Strong Names

If you want to share an assembly by putting it in the GAC, it must have a strong name. A strong name defines the assembly's identity: its name, version number, and culture information (if it exists), a public key, and a digital signature.

2.8.1.1. Strong ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required