Fixing the “Could not load file or assembly AjaxControlToolkit” error with bindingRedirect

I was upgrading a web site to use a later version of the AjaxControlToolkit.dll. The file version of the new DLL was 4.1.60623.0. So I changed the DLL to the new version and rebuilt my project locally, and all was well with my pages, giving me that warm, fuzzy feeling like rum-infused egg nog. But that warm, fuzzy feeling went away when I tried to deploy it on this whole interwebs thing, when I got this error:

Could not load file or assembly ‘AjaxControlToolkit, Version=4.1.50401.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e’

The first thing I tried was screaming “WHY AREN’T YOU WORKING?” at the computer, but this did not seem to work. Which is odd – it usually does.

So the next thing I did was search, and I found something interesting: The bindingRedirect element, the documentation of which you can find on MSDN. So I modified my web.config file, adding this code inside the <configuration> element:

   <runtime>
      <assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″>
         <dependentAssembly>
            <assemblyIdentity name=”AjaxControlToolkit”
                              publicKeyToken=”28f01b0e84b6d53e”
                              culture=”neutral” />
            <bindingRedirect oldVersion=”4.1.50401.0″
                             newVersion=”4.1.60623.0″/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>

Tada! It worked.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: