Deployment problems with ASP.NET AJAX applications
In the last days I've seen several guys reporting problems while deploying ASP.NET AJAX applications to servers which only have ASP.NET 2.0 + ASP.NET AJAX 1 installed. Generally, the error that has been reported is:
Could not load file or assembly 'System.Web.Extensions, Version=3.5.0.0...
One of the suggestions that I have seen is to add a redirect on the web.config app so that all requests made to the 3.0 dll are redirected to the 1.0 version of the dll. Even though most guys said that this worked, I didn't though it was the correct thing to do since I was positive that if you specify the correct version of the ASP.NET Ajax dll on the config file and that file existed on the server then you should get that file and not the most recent version.
Today, I've finally managed to get a repro web app from Johnson (thanks!).Since this kind of thing will only happen if you have the .Net 3.5 framework installed, I started by looking at the web.config file. I though that VS might have changed the dll version silently, but no, that was not the case. Then I asked Johnson how he was deploying the app and he told me that he was publishing the app from within the VS. Since I'm running VS 2008 standard, I don't have that option here. So I asked him to publish the site and sent it to me by mail. This was really a simple site that only had one page with an UpdatePanel (or something simple like that)
After looking at the pre-compiled version, the problem was obvious: the assembly that was placed inside the /bin folder (built automatically when you publish the web app form within VS ) had a dependency on the 3.5 version of the System.Web.Extensions assembly!
The moral of the story is simple: if you're using VS 2008 and you want to build a 1.0 ASP.NET AJAX web app to deploy on a server which is running version 2.0, then don't forget to set up the version you're compiling against on the property pages of the web project. This is specially true when you're using the publish option, since it'll pre-compile the web app and this will create dependencies between the resulting dlls and the platform dlls (which might not be installed on the server where you're deploying the app).
You should also pay attention to external dlls that are added to your project. For instance, if you're using the AJAX Toolkit, then you should check its dependencies and make sure that it was built against the correct version of System.Web.Extensions.dll.