
Additional Resources | 155
User and
Server Controls
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
given machine. Adding your own control assemblies to the GAC is a relatively
straightforward process that requires four steps:
1. Use the sn.exe command-line utility to create a public key pair for use in
signing your control:
sn.exe -k Blog.snk
2. Add the AssemblyKeyFileAttribute to the file containing the control code,
passing the path to the keyfile created in Step 1 as an argument. (This is an
assembly-level attribute, so it should be placed outside of any namespace or
class definitions.) When compiled, this attribute will result in a strongly
named assembly that can be placed in the GAC:
[assembly: AssemblyKeyFileAttribute("Blog.snk")]
3. Recompile the control.
4. Add the control to the GAC, either by dragging and dropping the assembly in
Windows Explorer or by using the gacutil.exe utility, as follows:
gacutil -i Blog.dll
Note that as with the csc.exe and vbc.exe command-line compilers,
using the sn.exe and gacutil.exe utilities without a fully qualified
path requires that you have the path to these utilities registered as
part of your PATH environment variable. The sn.exe and gacutil.exe
utilities are typically located in the \FrameworkSDK\bin directory,
which is installed either under ProgramFiles\Microsoft.NET or Pro-
gramFiles\Microsoft ...