24

When I load up my VS2013 projects in 2015, all my razor views are filled with red squiggly underlines.

@model, @Scripts @url, @Html.Partial, lambda expressions

Intellisense is now fairly useless as it seems to be missing half the options.

Solutions I've seen involved deleting .vs folder, and devenv.exe /ResetUserData, however these don't work for me.

I'm on a fresh install of VS 2015 Community using the same install files as my colleagues. None of them have the razor issues, and they're working on the same projects as I am.

Any idea how to fix this?

Edit...Further Info! I uninstalled/reinstalled VS 2015 Community, opened my projects, and the razor worked! I then clicked on a notification saying to update NuGet. NuGet update installed, VS restarted, razor stopped working again. So the NuGet update is breaking razor??

Every time I open a razor file it says "An exception has been encountered. This may be caused by an extension. You can get more information by examining the file 'C:\Users\Jonathan\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml'. "

In the activity log I get the following error

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

How do I fix this?


  • I have the same issue, I had to go back using VS 2013... - Guigui
  • Bizarre. I've read quite a few people with this problem but no solutions for some. Some projects I open work perfectly fine but most don't. Yet for my colleagues they all work properly. I've switched back to VS 2013 for everything that doesn't work in 2015 :( - mejobloggs
  • On my machine, everything WAS working fine on VS2015 even with CodeDom compilers. Then, all of a sudden, I started to get the "System.Reflection.TargetInvocationException..." error on load of a script in the UI. Everything continued to compile and work fine, I just can't operate like this. I am retracing my steps to see if any extension is causing this, but it's incredibly frustrating and unproductive! - HumbleBeginnings
  • Did a complete repair on VS2015 Professional. Can't even get a brand new project to show Razor with no extensions installed! Arrgghh! - HumbleBeginnings
  • possible duplicate of Visual Studio 2015 Broken Razor Intellisense - Mormegil

14 답변


21

You dont need to reset the entire configurations of your Visual Studio using the devenv.exe /ResetUserData to workaround this

Instead of it, try to just delete the contents of this directory with Visual Studio closed then reopen it: %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache


  • Thanks for the ComponentModelCache-solution, it worked like a charm :) - kapsi

14

Here's what FINALLY worked for me: Start -> Run -> (Or Windows Key + R) Then type "devenv.exe /resetuserdata" (no quotes of course)

I did not have to delete the .vs file, as some others had experienced.

See also: Visual Studio 2015 Broken Razor Intellisense


  • Didn't work for me unfortunately. I mentioned in the original post that I'd tried both resetuserdata and deleting the .vs :( - mejobloggs
  • I'm sorry - I didn't see that in your OP -- I must have been going crazy. Just to confirm from my end -- I "did" the full repair, but don't think that was the issue. Also just in case make sure that VS is closed when you reset your environment. I don't think it's case sensitive but might be worth another try. Lastly - have you confirmed that your old devenv was renamed in "C:\Users(username)\AppData\Roaming\Microsoft\VisualStudio" ? Interestingly, what was renamed was my VS2013 I think. Not trying to belabor your pain, just trying to help, my friend. :) It is FRUSTRATING! - HumbleBeginnings
  • I kind of have to apologize for upvoting this answer since the OP did say he tried this, but it worked for me, so thanks for the reminder to try it. Good luck @mejobloggs :\ - pbarranis
  • This will work if Intellisense craps out completely. it won't help intellisense not working for razor. still worth an upvote. - Timothy Groote
  • @SpencerK You're welcome! Curious - are you saying that disabling your AV eliminated the problem sometimes? Not aware of that but if so it's good to know. As I mentioned before (I think) that I actually have a little cheat sheet that I use that is full if keyboard shortcuts that help re-setup my environment when I have to resort to using this fix. I would be far better for MS to find the issue and fix it (or tell us what is causing it) but at least it's better than reinstalling! Cheers! - HumbleBeginnings

5

I've upgraded to mvc5 and so forth to razer 3. It solved my issue.

I followed this instructions :

http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-21


  • I just wanted to say that I followed the guide, line by line, and it worked for me, even after I tried some of the devenv.exe commands suggested here. I've had the issue for a good few months now and I'm just happy that I finally got it resolved. - Shafiq Jetha

5

Had the same issue. ResetUserData didn't work, etc. What ResetUserData did do though was reset some of the dialogs that were suppressed. Ultimately a dialog popped up stating "The 'CompatiblityCheckerPackage' did not load correctly." It told me to go to my users folder (path below) and check out the ActivityLog.xml. Turns out WebEssentials 2015 did not install correctly and was failing to load. I installed WebEssentials again and the Intellisense errors went away.

Full Path for me:

C:\Users\xxx\AppData\Roaming\Microsoft\VisualStudio\14.0\ActivityLog.xml

Hope this helps.


5

This could fix similar problems (I got it from somewhere, unfortunately I cannot remember, on Github)

  • Close VS Studio
  • Run command prompt as Administrator
  • In command prompt:
    > cd "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE"
    > devenv /updateconfiguration
    > devenv /clearcache
    
    I hope the above will be helpful to someone.


  • answer worked for me :) followings are the clean & clear 3 lines of code those I run in cmd. C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE> C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>devenv /updateco nfiguration C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>devenv /clearcac he - Nadir

3

Deleting the entire Solution and re-downloading it from Source Control is the only thing that worked for me. You might need to open the solution in VS 2013 first before you can open it in 2015... a very buggy Visual Studio release Microsoft!

Edit: Another thing that is strange, at least for me... deleting the red zigzag underlined text then retyping it fixed the problem! Possibly just a random thing that happened to me.


3

I had same issue and none of these answers worked. What I finally saw was, my Views web.config file was referencing MVC 4, and my main web.config was referencing MVC 5. So I could compile fine but intellisense wasn't working. MVC 4 isn't supported in VS2015. Why my web.config files were different I don't know. When I updated MVC in VS2012 months ago it must not have updated that config file.


  • Thanks! This was just what I needed. I had assumed this was a web.config issue but hadn't thought to check the web.config file inside the Views folder! :) Cheers - Brendan

3

You don't to update anything.
Just delete component cache from this folder C:\users\xxx\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache And ot will work fine . Try it


  • In Visual Studio 2017 (Enterprise) I did something akin to this. In my case, there were several folders prefixed with "15.0" ... in the folder "C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\15.0_a895a793" I found the ComponentModelCache folder, deleted it, opened VS and I was back up and running. Thank you!!! - Bob Tabor

1

None of these solutions fixed it for me. What worked was ensuring my webpages version was up to date. So

<add key="webpages:Version" value="3.0.0.0" />

in the web.config, instead of version 2.0.0.0

And then closing and reopening visual studio with the same solution.


0

I am using VS 2015 professional. Faced the same issue, tried all mentioned above solutions and nothing worked. Neither "devenv.exe /ResetUserData" nor "deleting content of ComponentModelCache".

The only way I managed to solve the issue is by modifying the installation: Go to Program and Features -> Find Microsoft Visual Studio ... 2015 -> Click Change -> Select Modify -> Check "Microsoft Web Developer Tools" -> Click Update

That worked for me.


0

i have read a lot of solutions, a i have lose much time, and when i was sure to not resolve the problem of visual studio 2015 intellisense, eureka, some one was giving the right solution: lean & clear 2 lines of code those I run in cmd (like administrator):

  1. C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>devenv /updateco nfiguration
  2. C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>devenv /clearcac he

whe restart visual studio maybe it ask to reinstall one tools that was broked. Well you do but still fron now your intellisense is going work agane. good luck at all and much thanks at Nadir


0

Just do one thing and go to:

Tools > Extension & Update > Update Your Visual Studio Version

It take some time but after that working fine.


0

I know that this topic is out of date, but I've just overcome the same problem and my resolution is not related to any one of the listed here.

The issue is that in my project properties the parameter "Output path" (Build->Output) was a folder different from just "bin\". After changing it to bin\, reopening the Studio and rebuilding my project, everything worked out!

Hopefully, it might help someone.


-3

Just Put a Break point on the First line

of Page. and remove it after few seconds... it will definitely work...


  • There is no page class in ASP.NET MVC. What do you mean? - slfan

Linked


Related

Latest