locked
AppFabric assemby redirect RRS feed

  • Question

  • Hi,  we've got a WCF project that uses on-premises/Server AppFabric caching. We've been porting this project to Azure and I've run in to the problem of the Azure-AppFabric vs. Server-AppFabric assemblies being incompatible. We only do some simple caching so the API diffs aren't a problem, I can swap the assembly references in the project, change the configuration for Azure, build & deploy to Azure and it works great.

    So I thought I'd just swap-in the Azure-version assemblies when building the Azure deployment package and use assembly redirection in the web.config to tell the clr to use them instead of the on-prem version, but that's not working. Here's the <assemblyBinding> I tried:

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Client"
            publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="1.0.0.0-1.0.2912.0" newVersion="1.0.4202.0"/>
          <codeBase version="1.0.4202.0" href="E:\approot\bin\Microsoft.ApplicationServer.Caching.Client.dll" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
    

     

    So if anyone a) knows if that's possible and how to make it work, or b) has other suggestions on how to build the same project for different assemblies I'd appreciate hearing them.

    Thanks in advance!   - Ken

    Tuesday, June 28, 2011 7:08 PM

Answers

  • Hi Ken,

    Do you mean you add the reference to Windows Server AppFabric caching DLL and then want to swap it with a Azure AppFabric caching DLL using web.config?

    If so, I think using assemblyBinding should work. May be E:\approot\bin\Microsoft.ApplicationServer.Caching.Client.dll is not the proper DLL you intend to load. Please try to add a folder "temp" folder in your web role project and add the correct DLL file to that folder. Set the "Copy to Output Directory" as "Copy if newer". Then in assemblyBinding element, please use a relative path instead:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Client" />
                <codeBase href="bin\temp\Microsoft.ApplicationServer.Caching.Client.dll" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

    I tested the above approach by using my own class libraries as I haven't installed Server AppFabric caching SDK. I think it should work for your case too.

    Thanks.


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    • Marked as answer by Wenchao Zeng Tuesday, July 5, 2011 6:18 AM
    Wednesday, June 29, 2011 11:10 AM
  • Also, the assembly version for the Azure dll's is 101.0.0.0 - You need to use this instead  of the file version (1.0.4202.0)...
    • Marked as answer by Wenchao Zeng Tuesday, July 5, 2011 6:18 AM
    Thursday, June 30, 2011 1:24 PM

All replies

  • Hi Ken,

    Do you mean you add the reference to Windows Server AppFabric caching DLL and then want to swap it with a Azure AppFabric caching DLL using web.config?

    If so, I think using assemblyBinding should work. May be E:\approot\bin\Microsoft.ApplicationServer.Caching.Client.dll is not the proper DLL you intend to load. Please try to add a folder "temp" folder in your web role project and add the correct DLL file to that folder. Set the "Copy to Output Directory" as "Copy if newer". Then in assemblyBinding element, please use a relative path instead:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Client" />
                <codeBase href="bin\temp\Microsoft.ApplicationServer.Caching.Client.dll" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

    I tested the above approach by using my own class libraries as I haven't installed Server AppFabric caching SDK. I think it should work for your case too.

    Thanks.


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    • Marked as answer by Wenchao Zeng Tuesday, July 5, 2011 6:18 AM
    Wednesday, June 29, 2011 11:10 AM
  • Also, the assembly version for the Azure dll's is 101.0.0.0 - You need to use this instead  of the file version (1.0.4202.0)...
    • Marked as answer by Wenchao Zeng Tuesday, July 5, 2011 6:18 AM
    Thursday, June 30, 2011 1:24 PM
  • Hi,

    I will mark the reply as answer. If you find it no help, please feel free to unmark it and follow up.

    Thanks.


    Wengchao Zeng
    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Tuesday, July 5, 2011 6:18 AM