locked
bindingRedirect with Codebase not working RRS feed

  • Question

  • I have a CF application which needs to use bindingRedirect to load appropriate versions of dlls.  The dlls are located in a folder structure underneath the application folder.

    My BindingRedirect works, the CF looks for the new version of the dll, and if it's located in the app directory, everything works.  What does not work is using the codebase to find the file in a specific location.  We've been doing this on the desktop for years without issue, but I can't get it to work on the CF.

    Here is my configuration file:

     

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="MyCompany.MyLibrary" publicKeyToken="myPKT" />
            <bindingRedirect 
              oldVersion="0.0.0.0-1.0.0.0" 
              newVersion="1.1.0.0" />
            <codeBase 
              version="1.0.0.0"  
              href="file://\Program Files\MyApp\lib\v1.0.0\MyCompany.MyLibrary.dll" />
            <codeBase 
              version="1.1.0.0"  
              href="file://\Program Files\MyApp\lib\v1.1.0\MyCompany.MyLibrary.dll" />        
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    I've tried several versions of formatting the href.   relative, with or without the leading "\", with or without "file://", nothing seems to work.  And again, the redirect IS working, it correctly looks for the 1.1 version, it just can't find it.

    Any ideas as to why this isn't working?
    Wednesday, April 15, 2009 4:32 PM

Answers

  • Hi,

    It's not going to work because the .NET Compact Framework does not support codeBase locations as of now. You need to put the DLLs in GAC, in the root directory of the device, or in the application base directory (but not in its sub directories). The following is an excellent article which explains how .NET CF locates assemblies:
    .Net Compact Framework: Versioning, Strong Names and the Global Assembly Cache – Part 2


    Regards,
    Chunsheng Tang
    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    Monday, April 20, 2009 6:47 AM