Razor 智能感知在 VS 2015 中不起作用

标签 razor intellisense visual-studio-2015

当我在 2015 年加载我的 VS2013 项目时,我所有的 Razor View 都充满了红色波浪形下划线。

@model, @Scripts @url, @Html.Partial, lambda 表达式

Intellisense 现在相当无用,因为它似乎缺少一半的选项。

我见过的解决方案涉及删除 .vs 文件夹和 devenv.exe/ResetUserData,但是这些对我不起作用。

我正在使用与我的同事相同的安装文件全新安装 VS 2015 社区。他们都没有 Razor 问题,而且他们和我在做同样的项目。

知道如何解决这个问题吗?

编辑...更多信息!
我卸载/重新安装了 VS 2015 社区,打开了我的项目,然后 Razor 工作了!
然后我点击了一个通知,说更新 NuGet。安装 NuGet 更新,重新启动 VS, Razor 再次停止工作。所以 NuGet 更新正在打破 Razor ?

每次打开 razor 文件时,它都会显示“遇到异常。这可能是由扩展引起的。您可以通过检查文件 'C:\Users\Jonathan\AppData\Roaming\Microsoft\VisualStudio\14.0 来获取更多信息\ActivityLog.xml'。


在事件日志中,我收到以下错误

"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'RazorSupportedRuntimeVersion' Key being added: 'RazorSupportedRuntimeVersion' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.Add(Object key, Object value) at System.Collections.Specialized.HybridDictionary.Add(Object key, Object value) at Microsoft.VisualStudio.Utilities.PropertyCollection.AddProperty(Object key, Object property) at Microsoft.VisualStudio.Html.Package.Razor.RazorVersionDetector.Microsoft.Html.Editor.ContainedLanguage.Razor.Def.IRazorVersionDetector.GetVersion(ITextBuffer textBuffer) at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorUtility.TryGetRazorVersion(ITextBuffer textBuffer, Version& razorVersion) at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorErrorTagger..ctor(ITextBuffer textBuffer) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, Object[] args) at Microsoft.Html.Editor.ContainedLanguage.Common.ContainedCodeErrorTaggerProvider`1.CreateTagger[T](ITextBuffer textBuffer) at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)"

我该如何解决?

最佳答案

您不需要使用 devenv.exe /ResetUserData 重置 Visual Studio 的整个配置。解决这个问题

取而代之的是,尝试在关闭 Visual Studio 的情况下删除此目录的内容,然后重新打开它:%LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache

关于Razor 智能感知在 VS 2015 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31644895/

相关文章:

c# - CSC : error CS7038: Failed to emit module

asp.net-core - 表中的 EditForm 不呈现

documentation - SSMS 的 IntelliSense 是否具有类似于 Visual Studio XML 文档注释/支持数据库对象摘要的功能?

javascript - App_Code 和 Javascript 中的 Razor Helper

使用智能感知进行 Ruby 编辑

c++ - 对象从返回值构造而无需复制或 move 构造函数

c# - 转换服务定义.csdef

visual-studio - WindowsSDK_IncludePath在哪里定义?

c# - JqG​​rid 搜索选项 : toolbarsearch vs standard search window

jquery - Webmatrix - 跨页面保留查询字符串