locked
Can a .NET web application be directed to use components of a different version than what it was compiled with? RRS feed

  • Question

  • User-972501089 posted

    I'm trying to get some web services functioning that apparently were not compiled/packaged correctly by the software vendor (and it's several years old and the vendor no longer exists........yay...) After installing the web services application, using the Depends.Net utility, I can see that two of the dependencies in the manifest are completely wrong version numbers, that are ancient compared to the versions of those components that they included within the bin directory.

    I haven't done any .Net development in ages, and I admit to being pretty clueless here.

    I've tried adding a redirection in web.config, something like:

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Link.Services" publicKeyToken="30cbdfc4e43d944a" culture="neutral" />
          <bindingRedirect oldVersion="1.0.1260.10042" newVersion="7.6.0.0" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

    However that had no effect whatsoever. I continue to get the error:

    Could not load file or assembly 'Link.Services, Version=1.0.1260.10042, Culture=neutral, PublicKeyToken=30cbdfc4e43d944a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    Am I approaching this the wrong way? Is there some other way to update the application to look for the correct version of the component it depends on when you don't have access to the source to recompile it correctly?

    Thank you for your time!

    Monday, October 1, 2018 1:15 PM

All replies

  • User283571144 posted

    Hi MightyGorilla,

    Am I approaching this the wrong way? Is there some other way to update the application to look for the correct version of the component it depends on when you don't have access to the source to recompile it correctly?

    According to your description, I suggest you could firstly make sure you have install the Link.Services "7.6.0.0" in your application path or GAC and remove the "1.0.1260.10042" version.

    Then I suggest you could try to use below config setting.

    This will redirect all the "Link.Services" to "7.6.0.0" .

     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Link.Services" publicKeyToken="30cbdfc4e43d944a" culture="neutral" />
          <bindingRedirect oldVersion="1.0.0.0-7.6.0.0" newVersion="7.6.0.0" />
        </dependentAssembly>
      </assemblyBinding>

    Best Regards,

    Brando

    Tuesday, October 2, 2018 3:21 AM
  • User-972501089 posted

    Hi Brando,

        I appreciate the reply. What you describe is what I've tried. "Link.Services 7.6.0.0" is currently in the application directory with the other components. Except that I haven't removed any old versions of the components- because 7.6.0.0 was the only version provided by the vendor. It seems that they distributed the application with the right components, but mistakenly compiled it against some outdated components that were still hanging around on their development system...

        Another thing that I should mention is that "Link.Services" is a dependency of "RSI.Client", which is a dependency of the main web application. So is there anything special that needs to be done for the binding redirect, given that "RSI.Client" is the correct version that the web application is expecting, and it's a "dependency of a dependency" that's not being satisfied?

    • Web Application
      • RSI.Client 1.0.2439.11900 - present & accounted for.
        • Link.Services - RSI.Client expects old version, but they only provided a newer version. 
        • other dependencies of RSI.Client are all accounted for...
      • other dependencies of the web application are all accounted for...

    Thanks!   

    Tuesday, October 2, 2018 12:05 PM
  • User283571144 posted

    Hi MightyGorilla,

    If the provider just provide the new version, there are no way to let the dll convert to the old version, since dll will not contain the old version codes.

    I suggest you could try to contact to the provider to ask for the old version Link.Services.

    Best Regards,

    Brando

    Wednesday, October 3, 2018 5:52 AM
  • User-972501089 posted

    Thanks Brando,

         So to be clear, you're saying that Binding Redirects only function at the "top level"?

    Meaning that a particular dll referenced within the application can be redirected to an alternate version,

    but any dependencies of that dll cannot be redirected in any way?

    Thank you!

    Wednesday, October 3, 2018 3:44 PM
  • User-972501089 posted

    For the sake of anyone else reading this, I'll add that I was successful in redirecting to a different version of the top-level .dll within the application, but everything I tried failed to redirect any of the dependencies of any of those top level .dlls!

    Wednesday, October 10, 2018 8:15 PM