尝试解析标签帮助程序指令"@addTagHelper"时遇到意外错误 [英] Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper'
问题描述
我正在使用Visual Studio 2015社区版,并且创建了一个ASP.NET MVC 5项目.
I'm using Visual Studio 2015 Community edition, and I've created an ASP.NET MVC 5 project.
当我打开一个视图(Home
的Index
或任何其他视图)时,它显示页面的前三行带红色下划线,这是语法问题.这是错误:
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:
尝试解析标签助手时遇到意外错误 指令'@addTagHelper',其值为'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper,Microsoft.AspNet.Mvc.Razor'. 错误:对象引用未设置为对象的实例
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
屏幕截图:
构建项目时,它会成功构建.当我运行它时,它会显示很多错误,但是会运行该应用程序.
When I build the project, it build successfully. When I run it, it shows a lot of errors, but it runs the application.
名称空间中不存在类型或名称空间名称'Mvc' "Microsoft.AspNet"(您是否缺少程序集引用?)
The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)
和
'_ Page_views_home_index_cshtml.ExecuteAsync()':没有合适的方法 被发现覆盖
'_Page_views_home_index_cshtml.ExecuteAsync()': no suitable method found to override
我该如何摆脱呢?
推荐答案
这是我解决此问题的方法:
Here's how I fixed the issue: