I recently updated our projects from .Net 4.0 to .Net 4.6 and decided to also update from MVC 4 to MVC 5. I updated all NuGet packages and all projects builds and compiles, but if I open any of the .cshtml files, I can see that ViewBag.Title is underlined with an error saying:
Error 1 One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?
I also get another error (please note that the image below and error in the quote block below are related):
Error 2 The type arguments for method 'System.Web.Mvc.Html.SelectExtensions.DropDownListFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>, System.Collections.Generic.IEnumerable, string)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
The issue in the error above is that Html.DropDownListFor
does not recognize the m parameter and thinks it is dynamic, which it is not. I have the @model CallStatisticsModel
at the top of the .cshtml page. The quote block contains the full error description.
I am well aware that issues like these have been posted (and solved) before, and I have tried (the last 8 days) to get to a solution and testing out what worked for others, who had the same issues, but with no luck. What I have tried, includes:
- Uninstalling and installing NuGet packages related to MVC, Razor and WebPages
- Double checked and triple checked that version numbers in web.config and /Views/web.config are correct
- Checked that the .csproj file for the .cshtml file in question are referencing the correct MVC, Razor and WebPages references
- Followed this guide
- Googled (a lot)
- Tried rebuilding the project itself and the entire solution
- Reopened Visual Studio (2013)
Any advice, comment, or point in the right direction would be much appreciated, as this has been a great issue for me for over a week now.
Thank you all in advance!