How to – Upgrade to a New Version of AjaxControlToolkit

So you have a website that has been using one of the older versions of AjaxControlToolkit and you want to upgrade to a newer one, may be to the latest one as in my case. Of course, in my case I am not using a pre-compiled toolkit DLL, instead I am using the source code to compile from, since I am planning to make some customization on the source code for my needs.

I can assure you that you will be having lots of issues, error messages, problems along the way. It can be a long and tiring journey for some of you. Below you will see how I have overcome several problems while migrating from a 2009 version to the latest one (Nov 2011).

You downloaded the source (might be extracted in a directory like: ajaxcontroltoolkit-edf1fbcb2745 AjaxControlToolkit_edf1fbcb2745ServerAjaxControlToolkit), compiled it, added to the references of your existing website and built your site, bam! Error messages come one after another.

Here is alist of what you may encounter and how you can overcome them.
Note: Problems are not (or may not be) in the order of happening.

Problem 1:

Assembly “AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e” does not contain a script with hash code “f9cec9bc”.”

The reason for this error is the GetHashCode() method used in ToolkitScriptManager.cs class.

The reason is that the request being sent to retrieve the combined javascripts of the control used in the page contains a hash code that is used internally. That hash code is being generated from the script’s name using the default string.GetHashCode function which returns different values for 32 bit and 64 bit processes.
If your 64 bit process creates the javascript include call which contains the 64 bit hash code and the request will eventually reach the 32 bit process/machine you will get this error since the hash value will not be found internally and vice versa. (

So you can try one of the below:

1- Customize the ToolkitScriptManager.cs class to use a better and more stable hashing method
2- Try debugging on a 32-bit architecture and use the produced DLL
3- Set CombineScripts=”false” in your ToolkitScriptManager components on your pages.

Problem 2:

Assembly 'AjaxControlToolkit, Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' contains a Web resource with name 'MicrosoftAjax.js', but does not contain an embedded resource with name 'MicrosoftAjax.js'.

Apparently AjaxControlToolkit is unhappy because it can not find MicrosoftAjax.js file among its' embedded resources as also indicated by AssemblyInfo.cs file of the toolkit.

Assuming you have extracted the files to the previously mentioned directory, you will find MicrosoftAjax.js javascript file under: ajaxcontroltoolkit-edf1fbcb2745 AjaxControlToolkit_edf1fbcb2745 SampleWebSites AjaxClientWebSite Scripts MicrosoftAjax

What you need to do is copy the MicrosoftAjax.js javascript file, paste it into AjaxControlToolkit Solution and set its' “Build Action” as “Embedded Resource”.

Now you can rebuild the AjaxControlToolkit solution, copy the contents (or just the single .dll file) of the “bin/debug/” folder (assuming you are using the default build directory) to your websites “bin” folder and rebuild your website.

You will see that you are no longer getting the error message above, but now it will be asking for the MicrosoftAjax.debug.js file. Do the same thing for this javascript file, compile the solution and use the produced .dll to see what is going on.

Toolkit will be asking for a series of other javascript files to be included in the solution as embeded resource here is the list.

Add them all to the root folder of AjaxControlToolkit solution and change their Build Action to Embeded Resource as I have described before.

From this point, when you build your website you may see it compile and run successfully but if you try to activate a toolkit control or load a page with a toolkit control you may be encountering similar embedded resource problems.

You can solve them all doing the same thing, but this time instead of adding the javascript files to the root folder of AjaxControlToolkit solution, you will be adding them to the related folders of the toolkit controls.

For example, if you are using AutoCompleteExtender control in one of your pages you are likely to get an error like this:

Again assuming you have extracted the source files to the previously mentioned directory, you will find AutoCompleteBehavior.js javascript file under:
ajaxcontroltoolkit-edf1fbcb2745 AjaxControlToolkit_edf1fbcb2745 SampleWebSites AjaxClientWebSiteScriptsMicrosoftAjaxextendedAutoComplete

What you need to do is copy the AutoCompleteBehavior.js javascript file, paste it under “AutoComplete” folder and set its' “Build Action” as “Embedded Resource”. (Do the same for AutoCompleteBehavior.debug.js)

You may be facing this “Embedded Resource Problem” whenever you need to use/load a toolkit control and solve it all the same way.

Problem 3:

You have fixed your problems, get the toolkit working for the components that you like to use and even made some customization to the way the code works.

You have the new version of AjaxControlToolkit.dll pasted into the “bin” folder of your site, you are ready to build your website once more and you get an error message out of nowhere, like below:

Do not panic it is probably a misunderstanding 🙂

Right-click on your project and click “Property Pages”.

Remove the reference for the existing AjaxControlToolkit and add the reference for your new AjaxControlToolkit.dll.

This should solve the problem.

Problem 4:

You may have customized “single control” DLLs on your pages that you had built referencing the older version of AjaxControlToolkit. What to do then?

You can rebuild those controls (DLLs) after removing the reference for the older toolkit version from their solutions, adding a reference for your new toolkit version, and then recompiling them to produce a new version of the control DLLs. Then add the new DLLs to your existing website. But unfortunately there is no guarantee that they will work.

Even though they may compile successfully, you are likely to get an error during runtime (execution of ScriptResource.axd) like this:

Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: baseType

You may need to add the new versions of the controls from your new AjaxControlToolkit and customize them again.

Good Luck,

One thought on “How to – Upgrade to a New Version of AjaxControlToolkit

  1. Another possible way to cure Problem 2 is to install the Nuget AjaxToolkit version to your project after you have added the AjaxToolkit source code. I don’t intend to modify the source, but sometimes I like to step through the code, which this allows. It did add some lines to web.config that I had to remove:

    but otherwise it seems ok.

Leave a Reply

Your email address will not be published. Required fields are marked *