Recently I had to work on a project developed on .NET 2.0 and this blog is on my experience with “System.Web.Extensions” dll. So after getting a brief introduction from one of my colleagues on what is the project is all about, I Checked out the project from the source safe and was eager to compile the project and see the output in my machine. Every damn developer' wish. All developers will agree with me on this, whatever you see or know about the project one gets a totally different feeling on seeing the code running successfully in his/her machine. Ok leave that and coming back to the point. After checking out the code I pressed F5 and here comes my first problem. The error which I got is pasted below.
“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”
Ok, the file may not be there I thought, but, where to find this file? I searched the web for answers but it was in vain. So I thought why not search for the file “System.Web.Extensions” in my system. So in search criteria I gave something like this “*Extensions.dll”. One of the files from the search result was “System.Web.Extensions.dll” in “Program Files\Reference Assemblies\Microsoft\Framework\v3.5” folder. So with this information I could figure out what is the actual problem. I have asked for a system with Visual Studio 2005 and .NET 2.0 pre-installed but the infra team gave me more than what I asked for. They installed VS 2005 and .NET 3.5. As the project was developed in .NET 2.0 it was searching for “System.Web.Extensions” dll of .NET 2.0 version, which unfortunately was not there in my system. The reason why there is no version of .NET 2.0 version of “System.Web.Extensions” is that .NET 3.5 comes with its own version of “System.Web.Extension” file versioned “3.5.30729.1”.
But how could the system look for version “1.0.61025.0” version of the dll? Then finally I got reminded that with .NET 2.0 most of the dll references are automatically embedded in the web.config file. On inspecting the web.config file I could see an entry as shown below.
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
So in the web.config the “System.Web.Extensions” dll referenced was that of .NET 2.0 and whereas the one available in my system belonged to the 3.5 version of .net. After doing some googling I came to know that there should be a “System.Web.Extensions” dll for the .NET 2.0 version ideally located at the “Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025”. When searched, there was no folder named “Microsoft ASP.NET” under the “program files” folder in my machine. So I narrowed down the problem that there is no dll for .NET 2.0. One thing which I would like to point out is the discrepancies in the folder structure. For AJAX controls targeting .NET 2.0 Microsoft adds a folder called “Microsoft ASP.NET” and dumps all the files whereas for .NET 3.5 they create new folders. Atleast the folder structure could have been kept same.
One of the advantages of .Net which we learned in our early days of .NET is that you can have multiple version of the same dll in the same machine. Keeping this in mind I thought I will try installing the “System.Web.Extensions.dll” for .NET 2.0. Downloaded the dll from the link here and installed the same. Once the installation was over the necessary files and folders were created under “Program Files” folder which was missing earlier.
Happy to solve this problem I hit the F5 button to see the output, bloody developers eagerness. I paid for my eagerness, here comes the next error.
|“There is no web named "/XXX". If this Web site exists on the server, check to make sure the FrontPage Server Extensions are installed, and that you have permission to access the server.”|
What on earth is happening? I had no other go other than solving the problem. As the error says there is no web site by the name, “XXX”, the best place to search for it was in IIS. Opened IIS and started searching for the website. What the heck, the website is available and why the hell VS is throwing this error. Is it gone mad or what? Ok let’s see the properties. Right clicked and saw the properties.
As you can see from the above screenshot, the Application Name textbox was empty. So I removed the application by clicking the Remove button and clicked Create button (Once you click the Remove button, it changes to Create).
Once you click the Create button the application textbox is filled with virtual directory name, in this case the name will be XXX.
After doing the above changes here comes the next problem. :(
|“The type 'System.Web.UI.ScriptManager' exists in both |
\184.108.40.206__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions
No not again I cried. I have installed the “Extensions” dll for .NET 2.0 because of that the Global Assembly Cache (GAC) has two versions of the same dll and now the system is confused as to which dll to load. This is something new, but I knew the solution. I need to remove one of the dlls from the GAC. Now how to do that? This didn't turn out to be hard. I need to just type the following command in the run (Start Menu—>Run…) window of windows.
This popped up the below window.
I tried clicking the delete button on the toolbar but here comes the next message.
Oh my god this is too, three and four much. Another Error! Till now the system was confused on which dll to load and with this error I was confused on what the hell is happening. Is there any end to my hardships? Till now searching in the web for the various problems I faced didn't give any results so I was thinking whether I will find any solution for this problem. But luckily some googling helped me to solve the above problem. The solution was very simple and weird. I had to copy the two dlls i.e. “System.Web.Extensions” and “System.Web.Extendions.Design.dll” to the bin folder of my website. This is to tell the framework that if there is more than one version of the same dll then load the one which is there in the bin folder. To test my solution I clicked F5 and there you have it, my website is up and running without any further hiccup. Wow, at last my probs have been sorted out. But I was little bit skeptical because of the various problems I faced one after the other. So to be on the comfortable side I started testing one or two pages in the website just to make sure I don't face any further problems. Luckily my tryst with errors was finally over and I didn’t face further problems.
In the next blog we will see the hardships faced while installing Ajax Control Toolkit for .NET 2.0.