An unexpected error was detected while trying to resolve the tag helper directive '@addTagHelper'

I am using the Visual Studio 2015 community version and I created an ASP.NET MVC 5 project.

When I open the view ( Index of Home or any other), it shows the first three lines of the page, underlined in red as a syntax problem. Here is the error:

An unexpected error was detected while trying to enable support for the @addTagHelper directive tag with the value "Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNet.Mvc.Razor". Error: the reference to the object is not installed in the instance of the object

Screenshot:

@ AddTagHelper error message

When I create a project, it is successfully built. When I run it, it shows a lot of errors, but it launches the application.

View index with errors

The type or namespace name 'Mvc' does not exist in the Microsoft.AspNet namespace (do you miss the assembly reference?)

and

'_ Page_views_home_index_cshtml.ExecuteAsync ()': no ​​suitable method found to override

How can I get rid of this?

+53
c # asp.net-mvc visual-studio-2015 razor asp.net-mvc-5
Jan 21 '16 at 10:16
source share
3 answers

Here is how I fixed the problem:

First, clear the Visual Studio component cache by closing Visual Studio and deleting this folder:

C: \ Users \ [Username] \ AppData \ Local \ Microsoft \ VisualStudio \ 14.0 \ ComponentModelCache

Finally, check the web.config files and change:

 <appSettings> <add key="webpages:Version" value="2.0.0.0" /> ... </appSettings> 

at

 <appSettings> <add key="webpages:Version" value="3.0.0.0" /> ... </appSettings> 
+106
Jan 26 '16 at 19:09
source share
β€” -

I had the same problem, but above it did not work. I also deleted all 4 files in the cache of components that did not work. I noticed that the line below <appSettings> was set to false . I changed it to true and the red squitts disappeared.

 <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> 

+2
Feb 04 '17 at 19:00
source share

In my case, it was a link to System.Web.Mvc.

There were a lot of errors in the cshtml files, but it compiled and worked. Then I found that I had an error in the xxxcontrollers.cs file when trying to inherit the controllers.

It seems that it can compile because the DLL was already in bin, but it threw errors.

I could not rebuild this project. These would be days and days.

0
Jul 08 '19 at 2:05
source share



All Articles