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.
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.
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.
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.
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.
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.
For example, if you are using AutoCompleteExtender control in one of your pages you are likely to get an error like this:
ajaxcontroltoolkit-edf1fbcb2745 AjaxControlToolkit_edf1fbcb2745 SampleWebSites AjaxClientWebSiteScriptsMicrosoftAjaxextendedAutoComplete
You may be facing this “Embedded Resource Problem” whenever you need to use/load a toolkit control and solve it all the same way.
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.
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.