First, open a command prompt and browse to the appropriate .dll file. Type the following command (this example is for RichTextBox so substitute this for the appropriate control in your case).
gacutil.exe -i richtextbox.dll
Or if gacutil.exe is not available globally then browse to it’s installation folder at –
C:\program files\Microsoft VisualStudio .NET\FrameworkSDK\bin\gacutil.exe
or C:\program files\Microsoft Visual Studio .NET 2003\SDK\v1.1\bin\gacutil.exe if you're running VS 2003 so CD (prompt change directory command) to this Directory first then run gacutil.exe -i C:\Program Files\RichTextBox v2.0\Bin\richtextbox.dll
You can also run it directly from the Visual Studio.Net Command Prompt which is under Start/Programs/Visual Studio.Net/Visual Studio.Net Tools.
Note: you may also open an Explorer window at C:\winnt\assembly and another Explorer window at the .dll location and simply drap and drop the .dll into the Assemby folder which will add it to the GAC. This does not require gacutil.exe to be run.
Next, in web.config (for an application-wide setting) or machine.config (for a machine-wide configuration) add this:
<compilation defaultLanguage="c#" debug="false">
<assemblies>
<add assembly="RichTextBox, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=XXXX" />
</assemblies>
</compilation>
You can get the public key token from the GAC Viewer, which you can access by browsing to C:\WINNT\assembly or C:\Windows\assembly if you’re running Windows XP.
Note that to use 'code behind' against the DLL, you must still add a Reference to your project.
Following the steps above however does not mean that the newly added GAC assembly will automatically show in the VS.net Add references dialog box for all VS.net projects. To achieve this you also have to create a registry entry for your assembly (regedit) at –
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
Each assembly needs to have a key, with the name -Assemblyame.MajorVersion.MinorVersion.Build.Revision
For example, with RichTextBox 2.0 you’ll create a key name as RichTextBoxControl.RichTextBox.2.0.0.0
Then add the assembly location to the default string value key –
C:\Program Files\RichTextBox v2.0\bin\
Add the following into a .reg file and double click to run the import into the Local Machine registry –
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\RichTextBoxControl.RichTextBox.2.0.0.0]
@="C:\\Program Files\\RichTextBox v2.0\\bin\\"
If you’re running an earlier version of the control then substitute the 2.0.0.0 for the appropriate version. Select the .dll and right mouse/properties/version to get the appropriate version.
When you now open the Add References dialog from any VS.net project, the appropriate control should be in the list.