How to resolve Antlr3 dependency hell
Asked Answered
F

3

19

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?

Ferrigno answered 8/11, 2012 at 20:37 Comment(2)
RavenDB will remove the Antlr3 dep soonSprouse
@ayende-rahien Thank you Ayende for the info. Unfortunately I would have the same problem if another of my dependencies would depend on Antlr3. I mean the problem is not because of RavenDB but WebGrease who is using its own compiled version of Antlr3.Ferrigno
F
7

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

Ferrigno answered 15/11, 2012 at 23:30 Comment(1)
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)Paneling
E
1

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

Earreach answered 22/4, 2014 at 10:26 Comment(0)
M
1

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.

Mciver answered 28/9, 2021 at 18:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.