I'm using Visual Studio 2015 Community edition, and I've created an ASP.NET MVC 5 project.
When I open a view (Index
of Home
or any other), it shows first three lines of the page underlined with red as a syntax issue. Here is the error:
Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNet.Mvc.Razor'. Error: Object reference not set to an instance of an object
The screenshot:
When I build the project, it build successfully. When I run it, it shows a lot of errors, but it runs the application.
The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)
and
'_Page_views_home_index_cshtml.ExecuteAsync()': no suitable method found to override
How can I get rid of this?
Here's how I fixed the issue:
First, reset the Visual Studio Component Cache by closing Visual Studio and deleting this folder:
C:\Users\[Username]\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
And finally, check the web.config
files and change:
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
...
</appSettings>
to
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
...
</appSettings>
I had the same problem, but the above didn't work. I also deleted all 4 files in the Component cache which didn't work. I noticed that the line below
<appSettings>
was set to false
. I changed it to true
and the red squigs were gone.
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With