尝试解析标签帮助程序指令"@addTagHelper"时遇到意外错误 [英] Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper'

查看:292
本文介绍了尝试解析标签帮助程序指令"@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.

当我打开一个视图(HomeIndex或任何其他视图)时,它显示页面的前三行带红色下划线,这是语法问题.这是错误:

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:

首先,

C:\ Users \ [用户名] \ AppData \ Local \ Microsoft \ VisualStudio \ 14.0 \ ComponentModelCache

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

最后,检查web.config文件并进行更改:

And finally, check the web.config files and change:

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

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

这篇关于尝试解析标签帮助程序指令"@addTagHelper"时遇到意外错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆