当我在 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/