安装Web Essentials和Web Compiler后,Razor编辑器格式化不起作用。

8

我刚刚重新安装了Visual Studio 2015并安装了Web Essentials和Web Compiler扩展,但这些似乎引起了问题。

例如,如果在安装Web Essentials和Web Compiler之前,我正在编辑Razor视图,如果当前元素格式化了几个制表符,并且我按下回车键,光标会自动移动到正确的位置。

工作示例:

<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有关,因为以前没有这个问题。此外,在启动时我收到以下错误:

Error

而这似乎是ActivityLog.xml中的罪魁祸首

错误 编辑器或编辑器扩展

System.Reflection.TargetInvocationException: 调用目标上抛出了异常。 ---> System.ArgumentException: 项已经添加。字典中的键:“RazorSupportedRuntimeVersion” 正在添加的键:“RazorSupportedRuntimeVersion” 在 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) --- 内部异常堆栈跟踪的结尾 --- 在 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)


你尝试卸载这两个扩展了吗?问题还存在吗?你尝试只安装其中一个吗? - Tamas
@Tamas-SonarSourceTeam 是的,我试过了。 - Matthew Layton
你还有这个问题吗? - Tamas
@Tamas-SonarSourceTeam 我完成了。 - Matthew Layton
知道只有一个产品安装时是否出现此问题会很好。但是完全卸载并重新安装VS以从干净的状态开始是很繁琐的。所以我想这个问题归结为这个问题对你来说有多烦人... - Tamas
可能是Visual Studio 2015 Broken Razor Intellisense的重复问题。 - kri
1个回答

2
今天我也遇到了这个问题,通过阅读Visual Studio 2015 Broken Razor Intellisense的解答,我成功地解决了这个问题。以下是解决方案:

I solved this problem by resetting the user data

devenv.exe /resetuserdata

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接