Visual Studio Designer not Respecting Assembly Binding Redirection


So we recently came across an issue where Visual Studio 2005 and 2008 Designers were not respecting assembly binding redirection.

Scenario

We have a file which is now version 2 and stored in the GAC.  So the assembly version is 2.0.0.0.  We have some existing customers using version 1 so we want to be able to use Assembly Binding Redirection to point them to the new version of the assembly.

For more information on configuring this, check out Configuring Assembly Binding Redirection.

The web page has code like:

<tc:TestContacts ID="QuickContacts1" runat="server">
    <tc:AContact Name="Test Tester" 
        Email="test@test.com" 
        Phone="(999) 555-1212" />
    <tc:AContact Email="no@spam.thx" 
        Name="Mr. A. Nonymous" 
        Phone="(999) 555-1234" />
</tc:TestContacts>

We also have a Register Assembly line at the top that points to the 1.0.0.0 version of the file.  And we have an entry in our web.config that looks like this:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Tester1" publicKeyToken="6ace53ab3256c766"/>
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0"
                             newVersion="2.0.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

We could have done this in a policy file and got the same results.  So now we open this file in Design view inside Visual Studio and change a property of the TestContacts control.  For instance, adding an AccessKey.  Switching back to the Source view, we will now see:

<tc:TestContacts ID="QuickContacts1" runat="server">
    <samples.aspnet.cs.controls.acontact Name="Test Tester" 
        Email="test@test.com" 
        Phone="(999) 555-1212" />
    <samples.aspnet.cs.controls.acontact Email="no@spam.thx" 
        Name="Mr. A. Nonymous" 
        Phone="(999) 555-1234" />
</tc:TestContacts>

This breaks the site and it no longer works.

Note: Assembly Binding Redirection works find in other scenarios, it just doesn’t work right inside the Designer.

Resolutions

There are two ways to resolve this issue.

  • Don’t use Assembly Binding Redirection at all and just leave the 1.0.0.0 version of the file in the GAC.  You will see a lot of .NET files do this, there are versions for .NET 1.0, 1.1, 2.0, etc all inside the GAC at the same time.
  • Change the existing files so that the Register Assembly line at the top of the web page points to the 2.0.0.0 version of the file.

Keep in mind that this is only a problem if you are actively changing the older files already, if you don’t touch the file it will be fine since this issue is only with the Designer.  So since you are already updating the file, it is trivial to update this line also.

We are looking into this issue also, so there may be another resolution posted in the future.

kick it on DotNetKicks.com

Comments (5)

  1. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  2. Another issue we discovered is around this.&#160; This is a rather specific situation, check out the

  3. molotov says:

    Looks like this has made it into a KB article…

    >> This is fixed in Visual Studio 2008 Server pack 1 <<

    “The Visual Studio Designer does not Respect Assembly Binding Redirection” @

    http://support.microsoft.com/kb/955600

  4. assemblyBinding says:

    It looks like VS 2005 is no longer supported. What happened to 1 rev back?

  5. That is true, checking out our FAQ:

    Business and Developer products

    Microsoft will offer a minimum of 10 years of support for Business and Developer products. Mainstream Support for Business and Developer products will be provided for 5 years or for 2 years after the successor product (N+1) is released, whichever is longer. Microsoft will also provide Extended Support for the 5 years following Mainstream support or for 2 years after the second successor product (N+2) is released, whichever is longer. Finally, most Business and Developer products will receive at least 10 years of online self-help support.

    Check out: http://support.microsoft.com/gp/lifepolicy for more information.