Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor intellisense not working in VS 2015

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?

like image 273
mejobloggs Avatar asked Jul 27 '15 04:07

mejobloggs


People also ask

How do I enable IntelliSense in Visual Studio 2015?

I would try: In Visual Studio 2015, go to 'Tools | Options | Text Editor | C# | General both "Auto list members" and "Parameter information" should be checked. If that doesn't work I would try to disable ReSharper in VS2013 and try to get the normal intellisense working.

How do I enable IntelliSense in Visual Studio?

To access this options page, choose Tools > Options, and then choose Text Editor > C# > IntelliSense.

How do I enable IntelliSense in Visual Studio 2010?

1) Use the Tools->Options menu command, select the Text Editor->C# settings, and then check the two circled check boxes above (Auto-list members and Parameter information). IntelliSense will then be turned on and work fine.

How do I get IntelliSense in Visual Studio 2017?

To enable the new functionality, go into Tools > Options > Text Editors > C# > IntelliSense. Check the last two boxes under Completion for highlighting and filters. Activate IntelliSense Now, switch to the code-behind for the form, pull up IntelliSense for the FlexGrid, and you'll start to see some changes. Entering .


4 Answers

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

like image 139
fabriciorissetto Avatar answered Oct 20 '22 03:10

fabriciorissetto


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

like image 22
HumbleBeginnings Avatar answered Oct 20 '22 03:10

HumbleBeginnings


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

like image 33
Guigui Avatar answered Oct 20 '22 03:10

Guigui


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.

like image 21
Rusty Avatar answered Oct 20 '22 05:10

Rusty