Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve? Assuming assembly reference 'System.Web.Mvc

With reference to questions/26393157/windows-update-caused-mvc3-and-mvc4-stop-working. The quickest way to resolve the warning below?

Assuming assembly reference 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy.

like image 570
Simon Legg Avatar asked Jun 05 '15 10:06

Simon Legg


3 Answers

I've had this happen with my NuGet packages every once in a while. I haven't been able to identify exactly how it happens. (I assume user error.) I didn't need to upgrade anything to solve it, just clear the NuGet cache:

I use the nuget command line tool found here.

You can clear all caches with this command:

nuget locals all -clear

See: https://docs.nuget.org/consume/command-line-reference

You'll probably need to restart Visual Studio if it is open.

like image 172
Brian Merrell Avatar answered Nov 19 '22 21:11

Brian Merrell


As per the best answer to the question....

  • Update MVC package (Visual Studio > Right click project/solution > manage nuget packages > Updates > Microsoft ASP.NET MVC > Update)
  • Manually add the compilation assembly

but then

  • Find - System.Web.Mvc, Version=4.0.0.0
  • and replace with - System.Web.Mvc, Version=4.0.0.1

Which will find all the hidden references in the Views/Web.config files.

like image 29
Simon Legg Avatar answered Nov 19 '22 21:11

Simon Legg


Every time I have had this issue I always start by doing a rebuild which will clear your bin folder. You likely do not need to close and open visual studio, as I never have, and it should work.

If this doesn't work then try more complicated solutions like those above but this could be a quick, clean fix.

like image 1
Joao Ricardo Avatar answered Nov 19 '22 21:11

Joao Ricardo