Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've just rebuilt my machine with a fresh install of Visual Studio 2015. I've also installed the extensions for Web Essentials and Web Compiler but these seem to have caused a problem

Say for example, prior to installing Web Essentials and Web Compiler, if I was editing a Razor view, if the current element was formatted a couple of tabs in, and I pressed enter, the cursor would automatically tab to the correct place.

Working Example:

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

Non Working Example:

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

This as I'm sure you can understand is quite annoying!

I'm pretty sure it's something to do with Web Essentials or Web Compiler because this wasn't a problem before-hand. In addition to this, I am getting the following error on startup:

Error

And this appears to be the culprit in ActivityLog.xml

ERROR Editor or Editor Extension

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)

like image 839
Matthew Layton Avatar asked Sep 04 '15 07:09

Matthew Layton


1 Answers

This happend to me today and I fix the problem following the instructions from the accepted answer to this question: Visual Studio 2015 Broken Razor Intellisense

Here is the answer:

I solved this problem by resetting the user data

devenv.exe /resetuserdata

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

like image 116
kri Avatar answered Sep 25 '22 02:09

kri