6.3 Sharing Controls Across Applications
The architecture of the .NET Framework makes using a custom server control or other assembly as simple as copying that assembly to the bin subdirectory of your application and adding the appropriate directives and tags to your page. However, there may be times when you would like multiple applications on the same machine to be able to use the same control, without having multiple local copies of the control's assembly floating around.
Fortunately, .NET addresses this need with the Global Assembly Cache (GAC), a repository of shared assemblies that are accessible to all .NET applications on a given machine. Adding your own control assemblies to the GAC is a relatively straightforward process that requires four steps:
Once you've added the control assembly to the GAC, you can use it from any application on the machine. One caveat: to use custom controls that are installed in the GAC, you must supply the version, culture, and public key information for the assembly when adding the @ Register directive for the control, as shown in the following snippet (which should appear on a single line):
<%@ Register TagPrefix="aspnetian" Namespace="aspnetian" Assembly="Blog, Version=0.0.0.0, Culture=neutral, PublicKeyToken=6bd31f35fc9a113b" %>
If you've added your control to the Visual Studio .NET toolbox, when you use the control from the toolbox, the correct @ Register directive will be generated for you automatically.