ASP.NET AJAX Scriptmanager error
2 July, 2010 Leave a comment
I recently had a problem using ASP.NET AJAX where I got an error message something like this:
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).
I had no idea how a particular type could be incompatible with itself, so I checked Stack Overflow (easily the best question and answer site for programmers). I found a question about this problem, but none of the existing answers worked for me. I googled around a bit, and eventually solved the problem. So here’s the answer for anyone else who might have this problem:
I managed to fix it by adding this to web.config:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="126.96.36.199-188.8.131.52" newVersion="184.108.40.206"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="220.127.116.11-18.104.22.168" newVersion="22.214.171.124"/> </dependentAssembly> </assemblyBinding> </runtime>
I believe it forces the .net runtime to use the new versions of those assemblies.
I added this to the Stack Overflow question too, for posterity. That’s one of the cool things about Stack Exchange sites, the platform encourages questions to be solved properly, once and for all, and then easily found by anyone coming later.
Obviously it helped a lot of people – my answer fast became the top answer (by far) and I earned the rare “necromancer” badge for resurrecting an old question with a popular answer.
So there you go: if you found this through searching for answers to the above problem, I hope I’ve helped you solve it. If you’re in need of answers for programming, or a heap of other things, see if there’s a stack exchange site for you. If not, propose one.