Building and Deploying Assembly
- Open the StopWatchClassLib project in Visual Studio.NET. Open
the StopWatch.cs and modify
public class
StopWatch
to
public class
StopWatch : System.ComponentModel.Component
- Open the AssemblyInfo.cs and scroll down to the bottom of the
file and look for [assembly:
AssemblyKeyFile("")].
- Modify
it as follows:
[assembly:AssemblyKeyFile("..\\..\\StopWatchClassLibKey.snk")]
- Open a command window
and cd to the StopWatchClassLib
project directory. This can be easily done by following the steps below:
(a) Click on Start, Programs, Microsoft Visual Studio
.NET, Visual Studio .NET Tools, Visual Studio .NET Command Prompt.
(b) In the command window type the word cd followed by a space. Do not hit return.
(c) Keep the command window on left and bring up the
windows explorer on the right of the monitor.
(d) In the windows explorer, go to the director that
contains this file.
(e) Drag the StopWatchClassLib
directory from windows explorer to the command window.
(f) Set focus on the command window and hit return.
- In the command window,
now type the following:
sn -k StopWatchClassLibKey.snk
- This generates a key
pair for the application to use for Cryptography.
If you like to see the keys generated, type
sn -tp
StopWatchClassLibKey.snk
- This will output the key to the clipboard
and you can place it any where you want by clicking on Ctrl+V.
Alternately you can provide an output file name as follows:
sn -p StopWatchClassLibKey.snk
key.csv
- Do not close the
command window. We need it again for pushing the assembly to the global
cache.
- Now compile your
project in Visual Studio.NET.
- Using windows
explorer, view the following directory:
C:\WINN\Assembly
- This is the global
assembly cache into which our assembly will be added.
- In the command window,
now type the following:
cd bin\debug
gacutil /i StopWatchClassLib.dll
- gacutil stands for the Global Assembly Cache Utility. It
deploys your assembly into the global cache. Using windows explorer,
verify that the global cache contains your assembly.
- If you like to replace the key for an
assembly, type sn –R assemblyName
keyFile.snk and redeploy the assembly.