安装 Web Essentials 和 Web Compiler 后 Razor 编辑器格式不工作

Razor editor formatting not working after installing Web Essentials and Web Compiler

我刚刚用 Visual Studio 2015 的全新安装重建了我的机器。我还安装了 Web Essentials 和 Web Compiler 的扩展,但这些似乎导致了问题

例如,在安装 Web Essentials 和 Web Compiler 之前,如果我正在编辑 Razor 视图,如果当前元素被格式化为几个选项卡,并且我按下 enter,光标将自动跳转到正确的地方。

工作示例:

<ul>
    <li> <!--press enter here-->
        |<!--would put cursor here-->
    </li>
</ul>

无效示例:

<ul>
    <li> <!--press enter here-->
|<!--put's cursor here-->
    </li>
</ul>

这我相信你能理解,这很烦人!

我很确定这与 Web Essentials 或 Web Compiler 有关,因为这事先不是问题。除此之外,我在启动时收到以下错误:

这似乎是 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.ContainedCodeErrorTaggerProvider1.CreateTagger[T](ITextBuffer textBuffer) at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator1.GatherTaggers(ITextBuffer textBuffer)

这件事今天发生在我身上,我按照这个问题的公认答案中的说明解决了这个问题:

答案如下:

I solved this problem by resetting the user data

devenv.exe /resetuserdata

and remove the ".vs" folder in my project.