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.
As you can see from the pic above I get no intellisense at all, nor any kind of code coloring.
Any clue about how to fix it? Thanks in advance.
This has been recurring for me also and seems to be connected to extension updates but I have not yet been able to blame anything specific. What I have been able to discover is a less intrusive resolution.
In my case deleting the contents of this directory allows the IDE to recover:
%LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Edit: I just came across this one which might be handy too - Clear MEF Component Cache (Open VSIX Gallery)
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.
FWIW, I had this problem with VS 2015 Enterprise on two different machines. On one machine, resetting user data made the problem go away (for a while). On the other machine, I had to totally uninstall and reinstall VS, and the problem went away for a while. On both machines, the problem came back after I installed an extension (once when installing Web Essentials, once when installing Git Diff Margin).
I burned an MSDN tech support case, and the answer was... Yeah, it's a bug, MS knows about it, and they're working on it.
Not a particularly actionable answer, but an answer nonetheless...
EDIT: And on the subject of working around the problem, I've encountered the problem a few more times since I posted this "answer". Most recently, I installed an update to NuGet Package Manager, and when VS restarted it started having this problem. I ran devenv.exe /resetuserdata, but that didn't help; it was still broken. So I tried again (ran devenv.exe /resetuserdata) and, bada bing bada boom, the problem went away (for now). The moral seems to be something along the lines of "if at first you don't succeed..."