How To use BotDetect ASP.NET CAPTCHA from the .NET 1.1 GAC

This page contains step by step instructions how to deploy and use the BotDetect ASP.NET CAPTCHA as a (machine-level) globally available assembly, instead of using xcopy local deployment to every individual application's Bin folder.

Step 1: Add the Lanap.BotDetect.dll assembly to the .NET 1.1 GAC

This step applies both to your development machines and your production servers.

Method 1: Manually, using the Windows GUI

This option is simple and suitable if you need to do it just once or on a small number of machines.

  • From the Start Menu, choose Programs > Administrative Tools > Microsoft .NET Framework 1.1 Configuration > Manage the Assembly Cache > Add an Assembly to the Assembly Cache
  • Browse to the BotDetect CAPTCHA installation folder: C:\Program Files\Lanapsoft\BotDetect\ASP.NET 1.1\v2.0\Assembly\Lanap.BotDetect.dll

Method 2: Using the Command Line

This option is more suitable for automated installations, installations on multiple machines etc.

Run the following from the command line:

"C:\Windows\Microsoft.NET\Framework\v1.1.4322\gacutil.exe" /i 
  "C:\Program Files\Lanapsoft\BotDetect 2.0 CAPTCHA\ASP.NET 1.1\
  Assembly\Lanap.BotDetect.dll"

( don't forget to delete the extra line breaks after pasting )

[back to top]

Step 2: Add BotDetect to the list of available references in Visual Studio 2003

This step applies only to your development machines.

Method 1: The Microsoft-recommended approach

  • Run regedit.exe
  • Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\ v1.1.4322\AssemblyFoldersEx
  • Right-click this entry and select New Key
  • Name it Lanapsoft and set it's value to the Assembly sub-folder path in the BotDetect installation folder ( C:\Program Files\Lanapsoft\BotDetect 2.0 CAPTCHA\ASP.NET 1.1\Assembly )

Method 2: The "quick & dirty" approach

  • Copy Lanap.BotDetect.dll to the %WINDIR%\Microsoft.NET\Framework\v1.1.4322\ folder

[back to top]

Step 3: Configure your ASP.NET Web application to use BotDetect from the GAC

This step applies only to your development machines.

Adding a BotDetect reference to your project

If you completed Step 2, you can simply select Lanap.BotDetect.dll from the list of available assemblies in the ".NET" tab of the "Add Reference" dialog in Visual Studio 2003.

HttpHandler registration

Change the BotDetect Captcha handler registration in your application's web.config file from

<add verb="*" path="LanapCaptcha.aspx" 
  type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect"/>

to

<add verb="*" path="LanapCaptcha.aspx" 
  type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect, 
  Version=2.0.9.0, Culture=neutral, 
  PublicKeyToken=74616036388b765f"/> 

You can then deploy the modified web.config file(s) to the server to propagate the changes.

Note

If you use a different version of Lanap.BotDetect.dll, you must specify the exact version number in this declaration. Anf if you have a Developer Edition license and have modified the component source code, you should also sign the assembly first, as explained below.

[back to top]

BotDetect Source Code modifications and GAC deployment

(Developer edition only)

Differences from non-modified versions of BotDetect

  • Only official Lanapsoft builds of BotDetect ASP.NET CAPTCHA use the official Lanapsoft public/private key combination
  • All modified versions of the source code use a different key pair, and thus have a different PublicKeyToken value, which you must use in the web.config file instead of the default one
  • The source code distributed with the Developer Edition comes without a key file, and doesn't produce a signed assembly by default
  • If you want to place your modified version of BotDetect ASP.NET CAPTCHA in the GAC, you must first sign the assembly, using a key file of your own.

Using your unique private/public key pair for assembly signing in Visual Studio 2003

  • Run the sn.exe utility ( located at c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\sn.exe ) to generate a .key file – called, for the purposes of this example, custom.key
  • Copy that file to the BotDetect CAPTCHA .NET 1.1 source code folder, and use Visual Studio 2003 to add it to the solution (to the BotDetect project root)
  • To automatically sign the assembly after each build, add the following line to the AssemblyInfo.cs file in the solution:
    [assembly: AssemblyKeyFile("..\\..\\custom.key")]
  • After signing the assembly, you can add it to the GAC.
  • You can check your modified assembly's public key token after successfully adding it to the GAC
  • For each ASP.NET project using that modified copy of BotDetect, you must use that exact token in your web.config file HttpHandler registration line; e.g. change the
<add verb="*" path="LanapCaptcha.aspx" 
 type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect"/>

line to

<add verb="*" path="LanapCaptcha.aspx" 
 type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect, 
 Version=VERSION_GOES_HERE, Culture=neutral, 
 PublicKeyToken=TOKEN_GOES_HERE"/> 

[back to top]

letter
about