How to resolve Antlr3 dependency hell

12,809

Solution 1

Unfortunately I did not found a solution to conflicting dependencies of same version with different signatures.

But the good news is that one of the contributors of WebGrease, Howard Dierking, has answered my concerns by email. Here's his response:

Hi Maxime – sorry that you ran into this. I’m working to do a couple things to quickly resolve the issue:

1) Preparing an update to the antlr package with the latest antlr version – will test and push to nuget.org

2) Working with the WebGrease team to change their NuGet package so that it does not ship the antlr.dll but rather takes a package dependency – in talking with them, they were unaware that a package existed.

This should resolve the dll hell issue that you ran into. Hopefully this won’t take more than a couple weeks with the holidays.

Thanks,

_howard

Solution 2

I tried the other answers. I also tried many combinations of restoring, upgrading, downgrading, reinstallation of the WebGrease and Antlr packages. At runtime, I was still getting ReflectionTypeLoadException thrown with LoaderExceptions that displayed the version number (3.4.1.9004) of the older Antlr that had been replaced.

I also tried the following, which took me a couple days to test, and none of which resolved the issue:

  • Clearing the temporary files.
  • Reloading Visual Studio and the Solution.
  • Rebooting my development computer.
  • Removing the "Specific version" flag on references.

What finally worked was adding a binding redirect in the web.config file. Since the older version of WebGrease had not been updated by NuGet either, I replaced them both with:

</runtime>
    </assemblyBinding>
        <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

After recompiling and deploying my application, then it got rid of the complaints.

Solution 3

I had the same problem and solve it by deleting all the project from my computer, getting the latest version from the server and rebuilding all the nuget dependencies after the project loaded. You can try this, it worked for me.

It seems that some nuget dependencies leave some trash behind after being uninstalled and that's the only way to make a clean rebuild for all the solution

Share:
12,809

Related videos on Youtube

W3Max
Author by

W3Max

Developer, building things @ home and Radio-Canada W3Max on Twitter

Updated on June 04, 2022

Comments

  • W3Max
    W3Max almost 2 years

    I have a asp.net MVC 4 project with MEF and RavenBD.

    When the project loads it throws this exception : Could not load file or assembly Antlr3.Runtime.dll

    I have found that both RavenDB and WebGrease (installed with MVC 4) use Antlr3. But WebGrease comes with its own Antlr3 dll, signed by Microsoft - PublicKeyToken 31bf3856ad364e35

    Antlr3 default PublicKeyToken is eb42632606e9261f.

    RavenDB and WebGrease use the same version of Antlr3 3.3.1.7705

    How can I resolve this problem?

    • Ayende Rahien
      Ayende Rahien over 11 years
      RavenDB will remove the Antlr3 dep soon
  • angularrocks.com
    angularrocks.com almost 11 years
    currently experiencing same thing. Did you solve that? My WebGrace varsion 1.3.0 (latest from Nuget) my Antlr3.Runtime version 3.3.1.7705 (comes from Nuget)