139

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.

Any clue about how to fix it? Thanks in advance.

Matt
  • 70,063
  • 26
  • 142
  • 172
Cristian Merighi
  • 1,581
  • 2
  • 11
  • 9
  • 1
    Try starting a new web project using the default web template. If it is working then the issue is related to your project. At least it is easier to narrow it down. – Rosdi Kasim Jul 23 '15 at 08:24
  • Sorry Rosdi, I had to provide more details. I updated the text above accordingly. BTW, keeping googling I just found an open feedback here https://connect.microsoft.com/VisualStudio/feedback/details/1579142/-razor which reports my exact same issue. – Cristian Merighi Jul 23 '15 at 08:44
  • Try this: http://stackoverflow.com/questions/17598359/visual-studio-intellisense-messing-up?rq=1#comment32568566_17861414 worked for me – Knerd Jul 23 '15 at 13:04
  • Hi Knerd, fact is that I get no intellisense at all (see pic above). Feels to me more like a core visual studio issue than some wrong project settings (I get the very same issue in the default template views of a brand new project). – Cristian Merighi Jul 23 '15 at 15:03
  • This is how I fixed a very similar issue in VS 2015 RTM: http://stackoverflow.com/a/32308899/1551276 – Vladimir Abashin Aug 31 '15 at 10:23

17 Answers17

162

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)

brahnp
  • 2,286
  • 1
  • 15
  • 22
  • 6
    ResetUserData had worked for me, but the issue returned. This works and is much less intrusive (no need to restore all your extensions). – ChadT Sep 10 '15 at 23:29
  • 1
    Did not fix it for me. Renamed the `ComponentModelCache` to `ComponentModelCache-old` and was still crashing. I have to many extensions to reinstall so the ResetUserData flag is no option for me. – JP Hellemons Sep 11 '15 at 12:29
  • Only running the devenv.exe /resetuserdata command, and deleting the .vs folder did not do it for me. Combined with this answer, however, the problem appears to be gone. Thanks! – Tormod Haugene Sep 22 '15 at 07:39
  • 13
    This worked for me *without* running devenv.exe /resetuserdata – Jaecen Sep 22 '15 at 18:52
  • Happened again for me today and this fix worked. I guess there are additional problems that mean some cases need the full reset. I would certainly suggest trying this first though, much less pain. Glad it is helping others! – brahnp Sep 22 '15 at 21:10
  • 4
    This worked for me as well. I tried the resetuserdata command first, but that didn't seem to do anything. This worked right away! – yesman Sep 28 '15 at 07:18
  • Happened for me today on two separate projects. I think after an update to Web Essentials (not sure as also a Win10 system update on same day). This fix worked for me. – Jude Fisher Oct 02 '15 at 14:14
  • Happened to me just now after updating Web Essentials 2015. Deleting the ComponentModelCache fixed it. resetuserdata did not fix anything – Zeno Oct 16 '15 at 11:04
  • This worked perfectly for me given the exact same problem. – Vince Anzelone Oct 23 '15 at 21:51
  • 4
    It worked for me, it happened several times, and i always reseted the user data and it's awful, i use the [Roaming Extension Manager](http://blogs.msdn.com/b/visualstudio/archive/2015/07/31/roaming-extension-manager-control-and-consistency-down-to-the-last-extension.aspx) to make it more simple to reinstall the extensions – ivi.hamiti Oct 28 '15 at 11:38
  • 2
    Did not fix the issue in VS2015 Professional. Razor syntax highlighting and intellisense still do not work. No errors are displayed. – Justin Skiles Oct 28 '15 at 15:50
  • 1
    Great, thank you. I ran into a similar issue with Razor throwing an error and was able to easily restore the IDE with your help! Much better than having to uninstall/reinstall extensions! Thanks again! – Kendall Nov 11 '15 at 15:49
  • This worked for me, I tried the other possible fixes and this is by far the least intrusive. Thank You – TheZachHill Apr 01 '16 at 14:18
  • Absolute hero! I was struggling with an issue where I would get an "Operation Cannot Be Completed" error dialog when trying to open any .cshtml file and this fixed that! – Alex Woodhead Apr 15 '16 at 08:27
  • muche better than reseting all my user data, thanks! – TcKs Apr 24 '16 at 13:19
126

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.

testpattern
  • 2,110
  • 23
  • 27
Yanos
  • 1,511
  • 2
  • 11
  • 13
  • 14
    I didn't need to remove the .vs folder for this to fix my issue. resetuserdata was enough – Phil Jul 30 '15 at 14:07
  • I did the two actions at the same time, so I wasn't sure if the resetuserdata was enough. Thanks for the precision. – Yanos Jul 30 '15 at 14:50
  • This fixed it for me as well. Does anyone know what causes this? It is a complete pain because you have to re-install any tools and extensions (e.g. Web Essentials, Web Compiler, etc). I had right-clicked on a controller action and clicked "Add View..." when it happened to me. – Sam Jul 31 '15 at 08:13
  • 1
    I have VS 2015, Enterprise. This solution isn't working for this version. Is there any other possible solution? – Zeeshan Aug 06 '15 at 07:03
  • I am using VS 2015 Enterprise and the above solution worked for me without having to remove the .vs folders. – JanR Aug 10 '15 at 00:15
  • It doesn't seam to be related to the version... I have the Community edition and resetting did not work on my computer. – Andrei V Aug 10 '15 at 08:06
  • 1
    I have professional and this isn't doing it for me either – Shawn Aug 17 '15 at 19:41
  • WOW thanks a mil!!! that saved my day! i would say shame on Microsoft if not that they made such an amazing visual studio – CMS Sep 01 '15 at 23:08
  • 9
    Just make sure you run that from this folder "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\" specially if you have more than one VS installed on your computer. – Miguel Sep 24 '15 at 18:40
  • I had the same problem, "devenv.exe /resetuserdata" was enough to fix the problem. I didn't need to delete ".vs" folder. – Fabio Belz Oct 05 '15 at 14:09
  • 10
    For me `devenv.exe /resetuserdata` **did not fix** the issue! FYI: I dont get any errors but VS does not paint syntax for Razor views. – A-Sharabiani Oct 20 '15 at 15:51
  • 7
    Be aware that you will lose all your Visual Studio settings like extensions and credentials (of the account you're signed in)! VS must be closed before you run `devenv.exe /resetuserdata`. – fabriciorissetto Oct 25 '15 at 22:05
  • 1
    Did not fix the issue in VS2015 Professional. Razor syntax highlighting and intellisense still do not work. No errors are displayed. – Justin Skiles Oct 28 '15 at 15:50
  • Worked w/o removing .vs folder. – ChrisP Nov 17 '15 at 19:54
  • @Yanos What's the consequences of doing that? – Shimmy Weitzhandler Nov 25 '15 at 00:28
  • 2
    @Shimmy As said Sam and fabriciorissetto your user data are removed so it's like a new installation. You need to reinstall all extensions, and reconnect all services in VS. – Yanos Nov 25 '15 at 07:25
  • 1
    Worked for me. Just to give some more details, this happened to me after installing Web Essentials 2015 – Roberto Dec 03 '15 at 08:49
  • 9
    Before you use this command, know what it does. Aside from minor inconveniences such as logging you out of Visual Studio and reseting your windows, it also uninstalled several extensions and Resharper. Finding the correct versions to reinstall took longer than I expected. – Jason Dec 07 '15 at 17:39
  • This worked for me, visual studio 2015 community edition without service pack 1 (without removing folder). Also as @Roberto sayd, I also can blame to "Productivity power tools" as the possible guilty of this problem. Regards – Yogurtu Dec 29 '15 at 21:03
  • 4
    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. – Nilesh Moradiya Apr 05 '16 at 10:02
  • Also works for resetting Fortran syntax highlighting, using Intel Fortran. – SAL Jun 23 '16 at 07:58
  • I had to remove .vs folder. – BNL Jul 28 '16 at 19:33
  • This will teach me to copy/paste commands from an answer without reading the comments. Not only did this not work in VS2015, it wrecked my VS settings so I had to reconfigure everything. – oscilatingcretin Jan 17 '17 at 14:44
  • As mentioned by @Nilesh_Moradiya clearing out all the files in the ```\Microsoft\VisualStudio\\ComponentModelCache\``` directory will help resolve most if not all issues. This action may need to be repeated periodically. edit: Also mentioned by @brahnp and several others I see. – Rockin4Life33 Jun 15 '17 at 17:48
11

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..."

Bob.at.Indigo.Health
  • 9,166
  • 11
  • 51
  • 93
  • Some warning that this wipes away absolutely everything would be useful. My panel configuration is gone, my syntax highlighting is gone and the problem is still not fixed. :( How do I get my data back? – Henry Ing-Simmons Aug 11 '16 at 09:16
8

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.

Manually return the IntelliSense power to VS through the menu:
ReSharper >> Enviroment >> IntelliSense >> Fill the following:
enter image description here

And this is how the IntelliSense from VS should look:
enter image description here

Pang
  • 8,605
  • 144
  • 77
  • 113
NucS
  • 579
  • 7
  • 20
6

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.

Pang
  • 8,605
  • 144
  • 77
  • 113
Wakusei
  • 148
  • 3
  • 10
  • This solved the problem for me as well. When doing a repair on VS2015 via add/remove programs, I could see that Web Developer Tools wasn't even installed. Checking the box and completing worked. – Anders Jakobsen Aug 17 '16 at 12:45
4

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

  • Tried resetuserdata, delete vssc, clear componentcache and didn't work. After i tried this and It's Worked! Thank you – c0demaster Oct 05 '15 at 10:24
4

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#

Community
  • 1
  • 1
AlexanderD
  • 558
  • 9
  • 17
1

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.

ChronixPsyc
  • 457
  • 1
  • 7
  • 21
1

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.

Pang
  • 8,605
  • 144
  • 77
  • 113
Thomas.Benz
  • 7,303
  • 8
  • 33
  • 55
1

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

T-moty
  • 2,411
  • 21
  • 30
1

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.

So first I did: Uncheck all checkboxes for Text Editor-> All Languages->General Statement completion: enter image description here

After Click OK- Reopen Option Dialog again: And check all for the same section: enter image description here

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.

Eugene Bosikov
  • 790
  • 8
  • 12
  • Common problem. What I read everybody had similar issues and it was always fixed in different way. I just shared what helped for me. Sorry, could not be solution for everybody. – Eugene Bosikov Jun 07 '16 at 21:17
1

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.

Pang
  • 8,605
  • 144
  • 77
  • 113
Colin
  • 1,188
  • 11
  • 18
0

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!)

  1. I copied all my code out of the files (.aspx & .cs) into notepad for example.
  2. Deleted the .aspx file (which in turn deleted all child files).
  3. Saved my project. Created a new .aspx file with the same name.
  4. Copy/pasted my code from notepad.
  5. Saved it.
  6. 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!

John Waclawski
  • 855
  • 1
  • 10
  • 19
0

This might sound funny but just to do one thing..

Put Breakpoint on any line and then wait for 5 seconds of that do not work then go to first line and put break point there and as you put break point it will ask for break point settings. enter image description here click on that settings and close that settings. Done. you intellisense is now working.

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.

Jay
  • 236
  • 1
  • 4
  • 11
0

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.

Nilesh Moradiya
  • 651
  • 1
  • 9
  • 18
0

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:

enter image description here

then chose to include folders:

enter image description here

The problem only shows up when you open an MVC website as a project, and not when you open it as a website directly.

Andy Brown
  • 4,841
  • 3
  • 29
  • 35
0

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

Community
  • 1
  • 1
Tony
  • 191
  • 2
  • 4