Search code examples
c#asp.net-mvcrazorintellisensevisual-studio-2015

Visual Studio 2015 Broken Razor Intellisense


After installing and then repairing my VS2015 instance I still cannot get intellisense (server side) to work in my MVC views. I get alerted by message prompt as soon as I open for the first time in a session an .cshtml file and get addressed to the Activitylog file. Error message retrieved in ActivityLog.xml (short version):

System.ArgumentException: Item has already been added. Key in dictionary: 'RazorSupportedRuntimeVersion'

Here's the full version:

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)

If it's any help, I have some font-coloring customizations, and have the Web Essentials, Bundler & Minifier and Web Compiler extensions installed.

UPDATE: it happens either when I open an existing web application or when I create a brand new one from scratch. There's also an instance of VS2013 installed and running on the same machine.

No intellisense at all

As you can see from the pic above I get no intellisense at all, nor any kind of code coloring.

How can this be fixed?


Solution

  • I solved this problem by resetting the user data

    devenv.exe /resetuserdata
    

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


    WARNING: this will reset all your user settings. Essentially, it is like resetting to factory defaults. You will lose any custom keyboard shortcuts, extensions you've installed etc.