Tuesday, January 6, 2009

Could not load file or assembly System.Web.Extensions Version=1.0.61025.0 Culture neutral PublicKeyToken or one of its dependen

So today I tried to download and compile one of my old ASP.NET projects on a new system and ran into a host of errors! First I thought someone had made changes and checked in buggy code but Vault showed no changes for a few weeks! Among others was the below error -

Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=
31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. C:\Users\Owner\Documents\Visual Studio 2005\Websites\...\web.config

The culprit here is the System.Web.Extensions DLL from the old 1.x version (as the error message indicates). And the solution is to just download and install the Ajax extensions (ASP.net Ajax).

The fun part though is - why Ajax extensions are required at all? That project doesn't use any of the Ajax controls! So why do we need to install an additional library? I guess it's because of the ASP.net Menu control being used in the project. But anyways, the solution is simple so let's just implement and get over with it!

Ajax Extensions can be downloaded from - ASP.NET AJAX 1.0

Once you download, install and restart your system, this particular error should disappear.

In some other cases though (specially for ASP.net Ajax Extensions 3.5 library), the installation doesn't seem to register the DLLs in GAC (Global Assembly Cache). If that happens, just register the following files in GAC -

System.Web.Extensions.dll (this is that ASP.NET Ajax Extensions file)

Please note that some of these files might already be registered in GAC so it might help to look them up first. Also, as you might already know, when checking if the file exists in GAC, always look at the name AND the version of the assembly because in .NET, just the name doesn't uniquely identify an assembly or DLL (this is how we can have System.Web.Extensions.dll Version 1.x and System.Web.Extensions.dll Version 3.x in the same folder in GAC).

So that should take care of the "Could not load file or assembly 'System.Web.Extensions, " error for all versions of System.Web.Extensions.dll

Happy coding and a very wishing a very happy 2009 to you!

To learn how to manage history with Ajax without using ASP.NET ScriptManager, click - Ajax History back button with RSH (Really Simple History)

To see a performance comparison of UpdatePanels with RSH, click - ASP.NET Ajax UpdatePanel slow performance compared to jquery and RSH - When to use and not use UpdatePanels

To learn how to catch textbox change event without using ASP.NET Ajax, click - Textbox onchange event in javascript / client side

No comments:

Post a Comment