Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies

.Netasp.net Mvc

.Net Problem Overview


I'm getting this error while trying to run my MVC4 project, it was working fine until last time on my other machines, but when I'm trying to run it from another machine it's giving me this error:

> Could not load file or assembly 'Antlr3.Runtime (1)' or one of its > dependencies. The located assembly's manifest definition does not > match the assembly reference. (Exception from HRESULT: 0x80131040)

After reading about this here I've tried to do:

> Install-Package Antlr3.Runtime -Pre

but it didn't help, any ideas?

.Net Solutions


Solution 1 - .Net

I encountered the same problem when experimenting with the free Nlog logging platform.

This helped me:

Enter %TEMP% in the File Explorer and delete all the temporary files.

After that I didn't get the error when starting my MVC5 project in Visual Studio.

Solution 2 - .Net

Try to delete the temporary files for ASP.Net by doing one of these:

  • Enter %TEMP% in the File Explorer and delete all the temporary files.
  • Go to folder "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files" and delete all files.

Solution 3 - .Net

Don't forget to clear also the Temporary ASP.NET Files in Framework64. That did the trick for me.

  • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
  • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

Solution 4 - .Net

Just in case this helps someone.
I had this problem with an MVC 5 Application. Deleting Antlr3.Runtime.dll from the bin directory and re-building fixed the issue.

Solution 5 - .Net

My problem was that the latest version of WebGrease installs version 3.4.1.9004 of Antlr. Once I installed WebGrease and then updated Antlr to version 3.5.0.2, the error went away.

Solution 6 - .Net

For me, removing this node in the web.config file got rid of the error message:

<identity impersonate="true" userName="" password="">

But what really worked for me was granting full access (to the userName specified in impersonate), to the Temporary ASP.NET Files" folder found in C:\Windows\Microsoft.NET\Framework{version} (or Framework64).

The identity might also be stored in the Web Site Application Pool Settings, in IIS.

Make sure your nuget package is correctly installed, with the correct version. If nothing else works, then just try re-adding the reference from a local folder and setting it to Copy Local.

Solution 7 - .Net

If any solutions solve your problem verify the web.config, the version of assembly

<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>

Solution 8 - .Net

The one of the simple way is update antlr and webgrease

  1. Goto Package console manager
  2. then try apply these codes one by one
  3. PM>Update-Package Antlr
  4. PM>Update-Package WebGrease

Finally the Error Solved

Solution 9 - .Net

There was problem with impersonate="true" in web.config, i removed the line it worked !!

Again i placed the line and gave admin permission to account user with impersonate, my whole application worked :)

Solution 10 - .Net

For me this was caused by a mismatch between the debug and runtime versions of Antlr.

Finally solved it by installing a different Antlr package: Install-Package Antlr

Solution 11 - .Net

Try to unlock the Antlr3.Runtime.dll if you add reference manually: enter image description here

Solution 12 - .Net

If you're using impersonation. The answer is to give permission for the user that you're impersonating access to the following folders :

  1. C:\Windows\Microsoft.NET\Framework[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files

  2. Your site directory.

also you might need to create folder as the following :

C:\Windows\Microsoft.NET\Framework\[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files\[Application-Name-Goes-Here]

But try the previous first, it worked for me.

Those two changes for granting the impersonated user permission to be able to save the temp data, and pull the dll files, and any needed files from the directories

Update, For windows 10 This is the solution that worked for me

We will do both steps, but Instead of C:\Windows\Microsoft.NET\Framework[v4.0.30319 or the version that you're using]\Temporary ASP.NET Files

Write %TEMP% into the file explorer, and give permission for the user that you're impersonating access to the following folder: C:\Users\[UserName]\AppData\Local\Temp\Temporary ASP.NET Files

Solution 13 - .Net

I got a simple solution. Go to your own project folder and find a packages folder.

enter image description here

Solution 14 - .Net

In a project I had reference to WebGrease, but there was not corresponding element in packages.config. I remove the reference from project, because I don't need it anymore. It works now.

Solution 15 - .Net

I tried all of the answers in this post, but none of them worked for me.

So I deleted all of the /bin directories inside all of the projects from my solution, cleaned and rebuilt the solution and it finally worked!

My whole morning wasted working to figure out the problem...

Solution 16 - .Net

what worked for me was removing the identity = true from my webconfig (under the system.web properties) and build the solution again and publish it again (if needed) and it worked like a charm!

Solution 17 - .Net

My problem ended up being caused by a change to the mapped drives in our Group Policy. My solution has the tempDirectory setting set in the Web.config to use a RAM drive setup as my Z: drive. Apparently they started using the Z: drive and the DLLs were getting copied to tempDirectory like normal, but then I think they were being deleted by a process on the remote server (Virus scan probably). I was only able to figure this out by using Process Monitor and filtering for Antlr and seeing that it was looking in a network location for the DLLs.

Solution 18 - .Net

I updated all packages in the Nudget Package Manager and it worked! In my case I'm hosting my website in GoDaddy

Solution 19 - .Net

After trying to delete .netframework temp file without success, I changed

<system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime />
    <pages controlRenderingCompatibilityVersion="4.0" />
</system.web> 

With only targetFramework="4.6" instead of 4.6.1 Web site displays without errors. Next I changed again to targetFramework="4.6.1" and restart server. Everything remains Ok.

Solution 20 - .Net

For me, the solution was to run Visual Studio as Administrator. It was apparently a permissions issue.

Solution 21 - .Net

Solution for me was to go Tools > NuGet Package Manager > Manage Packages for Solution

Then click Antlr3 and ensure it was installed in:

  1. The Startup Project
  2. Any libraries using reflection
  3. Any libraries calling the libraries that use reflection

In my case that was 4 Projects deep that needed it. Once that was done this issue was finally resolved.

Solution 22 - .Net

I just faced this issue and tried above mentioned solutions but nothing worked for now I had to delete it's dll from bin floder and rebuild and then delete all releated files from packages folder and restore packages using package manager console

Solution 23 - .Net

Deleted %temp%

Deleted bin

Deleted .vs

Now worked for me

Solution 24 - .Net

In my case, when I cloned a project, Visual studio 2019 replaced a spaces character with '% 20' in the project's path. Then, when VS tried to find the nugget packages, it could not find the correct path.

Solution 25 - .Net

I faced this issue after upgrading Microsoft.AspNet.Web.Optimization

update-package WebGrease and update-package Antlr (in that order) to get the latest versions and correct the Antlr version issue.

Solution 26 - .Net

For me, I did these steps and it's worked for me :

1 ) I deleted bin and obj folder (some files was not deleted by Clean project)

2 ) I checked some files like JS that was deleted a long time ago but they was included in project files. So I exclude them.

Solution 27 - .Net

This worked for me :

Tools > NuGet Package Manager > Manage Packages for Solution

Install de Antlr3.Runtime

enter image description here

> Microsoft Visual Studio Community 2019 (2) Version 16.10.3

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMavenView Question on Stackoverflow
Solution 1 - .NetAH.View Answer on Stackoverflow
Solution 2 - .Netsachin kulkarniView Answer on Stackoverflow
Solution 3 - .NetMathijs VlasveldView Answer on Stackoverflow
Solution 4 - .NetfhiltonView Answer on Stackoverflow
Solution 5 - .NetYeeHaw1234View Answer on Stackoverflow
Solution 6 - .Netlive-loveView Answer on Stackoverflow
Solution 7 - .NetDaniel MeloView Answer on Stackoverflow
Solution 8 - .Netdee panView Answer on Stackoverflow
Solution 9 - .NetMohamed Sanuj BasheerView Answer on Stackoverflow
Solution 10 - .Netedson-View Answer on Stackoverflow
Solution 11 - .NetADM-ITView Answer on Stackoverflow
Solution 12 - .NetMostafa ElabbadyView Answer on Stackoverflow
Solution 13 - .NetMd ShahriarView Answer on Stackoverflow
Solution 14 - .NetTomas KubesView Answer on Stackoverflow
Solution 15 - .NetVelociroundView Answer on Stackoverflow
Solution 16 - .NetAnchitView Answer on Stackoverflow
Solution 17 - .NetSchmallsView Answer on Stackoverflow
Solution 18 - .NetjoalcegoView Answer on Stackoverflow
Solution 19 - .NetLaurent DANEView Answer on Stackoverflow
Solution 20 - .NetAlexander van TrijffelView Answer on Stackoverflow
Solution 21 - .NetChris MoschiniView Answer on Stackoverflow
Solution 22 - .NetIkram ShahView Answer on Stackoverflow
Solution 23 - .NetArun Prasad E SView Answer on Stackoverflow
Solution 24 - .NetMartinView Answer on Stackoverflow
Solution 25 - .NetNishanView Answer on Stackoverflow
Solution 26 - .NetMostafa FallahView Answer on Stackoverflow
Solution 27 - .NetJRichardszView Answer on Stackoverflow