|only for RuBoard|
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 .
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.
The first step toward giving an assembly a strong name is creating a key pair file that contains the public/private keys used to sign the assembly. To create the key pair file, use the Strong Name tool from the command line:
sn -k hello.snk
Doing so creates a key pair file named hello.snk .
Next, you need to use the Assembly Linker (AL) to sign the assembly with the key pair file. This utility is not specific to any language, so you can't feed it source code. You do need to compile your library to a module first, using a command line like the following:
vbc /t:module hello.vb
Compiling your library produces a module called hello.netmodule . Now you can use AL to create a signed assembly like this:
al /out:hello.dll hello.netmodule /keyfile:hello.snk
The result is a signed assembly with the name hello.dll .
Now that you have a signed assembly, you can use the Global Assembly Cache tool, gacutil.exe , to install it to the GAC, as shown in the following command:
gacutil /i hello.dll
|only for RuBoard|