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.
https://i.stack.imgur.com/W1Waz.jpg
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.
devenv.exe /resetuserdata
did not fix the issue! FYI: I dont get any errors but VS does not paint syntax for Razor views.
devenv.exe /resetuserdata
.
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..."
Might have happened due to having ReSharper.
It will be fixed in future versions, but as of now (version 10.0.2), it is broken. ReSharper overrides the IntelliSense of Visual Studio and therefore it will not work, which also explains why running devenv.exe /ResetUserData
fixes it since it removes ReSharper.
https://i.stack.imgur.com/5YZCt.png
https://i.stack.imgur.com/LjgMb.png
I met the same problem, but the cause was different from the other answers.
An update of Visual Studio (I suspect TypeScript update on September 2015) uninstalled the Web Developer Tools component of Visual Studio 2015. That causes IntelliSense not to work.
I installed Web Developer Tools in the installer options again AND deleted ComponentModelCache after the installation. That worked for me.
This fixed it for me right away.
In Visual Studio:
Click Tools->Options->Text Editor->All Languages->General Uncheck "Auto list members" Uncheck "Parameter information" Check "Auto list members" (yes, the one you just unchecked) Check "Parameter information" (again, the one you just unchecked) Click OK
To add my 2 cents. None of the previous solutions worked for me, then I found this link:
http://www.c-sharpcorner.com/blogs/how-to-resolve-intellisense-issue-in-visual-studio1
In particular this one
Solution 4: Next, reset the Settings from the following location. Tools->Import and Export settings->Reset all settings.
From there I choose Visual C#
The /ResetUserData
solution is your best bet, but I also think I have found out a possible cause of this...
I am currently using Umbraco to create Macro Partials in the BackOffice. When these files get created I click on the Hide/Show all files button to show the Macro Partial in my solution and the Razor Syntax Highlighting seems to stop working so my guess is new files introduced into your solution that aren't created directly through VS cause this issue.
Even when adding the files to the solution the Syntax Highlighting doesn't work.
There is another solution, without reset all user data
(but only window layouts/toolbars):
close all VS2015 instances, [eventually backup, and] delete the folder:
"[User Directory]\AppData\Roaming\Microsoft\Visual Studio\14.0"
Now, re-open VS2015: layout was reset to factory preset, but Razor syntax would work
FYI: My VS 2015 PRO installation has full install with all 3-rd parties.
I tried all possible solution that here in article, it didn't help me. What Craig Goldensoph wrote helped me partially to find solution for me.
https://i.stack.imgur.com/ZDu6Z.png
https://i.stack.imgur.com/RmPQu.png
and apply settings again. You have to Restart your Visual studio. After restart it will take a time to load , but after that it worked for me.
Sometimes, the VS IDE does not show IntelliSense at all.
I just close the solution, close VS, then reopen it, and the problem is solved.
If none of the other options work, there is a workaround. After entering the '.' operator, press the "Ctrl + Space" keys which should force the IntelliSense dialog to appear.
I was having this issue when working with .cshtml MVC razor files.
This might sound funny but just to do one thing..
https://i.stack.imgur.com/kbRMM.png
I have VS 2015 Community edition.Previously had VS 2015 Enterprise and it happened on that but after getting community i found that same happens and same solution work for both.
I found that solution by accidently during work.Also do that when project is not running.and you can remove that break point also.
You don't need to reset everything just remove all files from %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
and restart VS, it'll be fine.
I've posted this answer on another SO question, just because I want to prevent people wasting the time I've just wasted. My problem was that I'd added files to a project, but not included them. So I chosen to show all files:
https://i.stack.imgur.com/6ONYm.jpg
then chose to include folders:
https://i.stack.imgur.com/pF3F7.jpg
The problem only shows up when you open an MVC website as a project, and not when you open it as a website directly.
I was only able to fix this by updating the webpages version, which I mentioned in another similar question:
Razor intellisense not working in VS 2015
Mine was a slight pain in the keester but seemed to work. In my case it was a .aspx File that wouldn't do intellisense anymore (after I stupidly changed the .aspx filename...lesson learned!)
I copied all my code out of the files (.aspx & .cs) into notepad for example. Deleted the .aspx file (which in turn deleted all child files). Saved my project. Created a new .aspx file with the same name. Copy/pasted my code from notepad. Saved it. Tried intellisense again. It worked!
Round about way but not as bad as uninstalling/vs reinstalling which is TOTALLY overkill. Good luck everyone! Hopefully MS will get this fixed one of these years!
Success story sharing