This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

Friday, 15 May 2009

Getting the Ajax Control Toolkit to work with Visual Studio 2005

Like many out there I have recently been problems attempting to get the Ajax Control Toolkit to work (correctly) in Visual Studio 2005.

After LOTS  of research it appears that most of the problems are caused by a mismatch of the referenced versions versions of the System.Web.Extensions namespace.  Just to clarify the errors that pop-up DO NOT usually mention this is the culprit.  For example the error the parser kept throwing at me was:

The base class includes the field 'ScriptManager1', but its type (System.Web.UI.ScriptManager) is not compatible with the type of control (System.Web.UI.ScriptManager). 

Now as you need a Script Manager on the page in order to use any of the controls in the toolkit this was really starting to get annoying.  I couldn't see anything wrong with the System.Web namespace, but as usual, I was looking in the wrong place.

To solve this problem involves the web.config file.

You need to check through this ensuring the versions for the System.Web.UI is using version 3.5.0.0 and NOT 1.0.61025.0

For example the line I had was:

<system.web>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
    </pages>
</system.web>


Which should have been:

<system.web>
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
    </pages>
</system.web>


Which completely solved my problem.

p.s. To find the solution of this problem I edited every instance of the version in the web config, although probably not required, doesn't seem to cause any problems.



No comments:

Post a Comment