Umbraco MVC4 IntelliSense not working - asp.net-mvc

I'm working on a few Umbraco projects that use MVC4. The MVC intellisense doesn't work within visual studio and I get lots of errors underlined. But when I run build the project, I don't get any errors, and when I run the site everything works fine.
I'm using Visual Studio 2013 and I created a new MVC4 site and compared the web.configs within the Views folder and they're identical.
I'm pretty sure it's not a code problem as my colleague is using the same code and he doesn't have this problem.
I've just done a fresh install of Visual Studio 2013.
Any ideas?
This could be a clue:
When I hover over #Htmlit tells me that my HtmlHelper is a System.Web.WebPages.Html.HtmlHelper instead of a System.Web.Mvc.HtmlHelper

The common one is to ensure that it is switched on (Visual Studio menu: Tools > Options > Text Editor > All Languages (or C# if you want it just for that language) > Tick "Auto list members", Untick "Hid advanced members", tick "Parameter information")
Once you've checked this, sometimes if you're using one HDD on Windows, because the disk has its bandwidth used up (particularly if using ReSharper then you need two or more drives ideally with the pagefile going to the non-OS drive I find). This is the case if the red lines do disappear after up to two minutes of not touching the IDE.
Finally check you project's references folder to make sure where the paths for your includes are coming from and that Visual Studio has permission to read from there. Permission issues cause all manner of problems I find, so when you launch VS, right click and choose "run as Administrator".
Hopefully one of these solves your problems. If not, then please update your question to explain how you create your project. Do you create an empty site or an MVC site? Do you then use Nuget to install Umbraco through the Package Manager Console like this?
Install-Package UmbracoCms

Related

Visual Studio 2015 "Not Responding" when adding an MVC controller or view

We are attempting to add MVC to an old, large, legacy webforms app. (The intent is to gradually re-implement portions of the app using MVC until the old app is gone).
Setting it up has gone smoothly. We have an MVC Area, and I created a controller which is accessible when running the app, by means on directly typing the url.
But whenever we "Add > Controller" or "Add > View"... Visual Studio hangs for around 10 minutes "Not Responding".
Clearly there is some bug in visual studio interacting with some quirk in our legacy project.
Googling, I have so far found only a few similar cases that are old & do not seem applicable.
Not sure where to begin resolving this.
UPDATE:
For what it is worth, we have converted the original VB webforms project to C#. I then added MVC Nuget package and and MVC area. Visual studio no longer seems to hang when adding controllers. So this might be a VB specific thing. Or maybe some windows update to visual studio fixed this in the interim since i posted this. Not sure.
The problem is still present in Visual Studio 2015 Update 1.
As a workaround, instead of selecting "Add View" you can select "New Item" and choose a page template from Web/MVC instead.
It is still in Visual Studio 2017; It takes time and you can restart making Controller/View or you can wait sometimes
this seems like bugs from visual studio,
you can copy other controller and paste it then rename namespace.
for temporary until visual studio is fixed.
I'm having the same issue. This should work. I'm selecting "Add Controller" from the context menu. It just spins saying Visual Studio not responding. This is with Visual Studio 2015.
In my case this situation arises when adding view to the controller and visual studio 2015 hangs indefinitely. However it creates the view file in the directory but not shown in solution explorer. I have manually copy pasted the file from directory to solution explorer and everything worked well.
Check if the below blog could help resolve your issue
http://digioz.blogspot.co.uk/2013/06/visual-studio-2012-freezes-or-crashes.html

Upgrading to Visual Studio 2015 renders intellisense broken for project

I've been through a lot of similar issues, but could not find anything that worked for me.
I'm upgrading my IDE from the VisualStudio for Web (v10) to Visual Studio 2015 (v14, I guess) Community Edition.
The main project that I'm trying to use on the new IDE is a MVC 5 (5.2.3), with EF 6.1 (6.1.3) and a bunch of other stuff.
Problem is: When opening the project on the new IDE, everything looks fine (it even compiles and work). I got the MVC context menu working on the project explorer (showing the "Add Controller..." and "Add View..." when appropriate). Only (really annoying) thing is the Razor Intellisense.
When I do open a View file (.cshtml) I receive warnings on several helpers, some of the "using" are greyed out (even though they're supposed to be needed) and the #model myModel is shown like everything after the #model directive is not razor (it's treated like HTML by the intellisense coloring).
What I've already found and tried:
I've already tried to clear the UserData from the vs (devenv /ResetUserData)
I've already tried to run the VS2015 in safe mode
I've already tried to run VS2015 as Administrator
I've already tried to set the Project's target framework to 4.5.1 (used to be 4.5)
I've already tried to open the project on Visual Studio Community 2013 saving it there before trying to use it on VS2015.
When creating another MVC project from the VS2015, everything works fine.
Here's an example of the annoying issue:
Ok, finally got it.
Posting what I found out believing it may help someone else:
What seems to cause the problem mentioned is the fact that the project was created on an old MVC version (with older Razor, EF, etc).
As stated in this answer: Visual Studio 2015 Razor View MVC Types not recognized, VS2015 tools may not work for older MVCs.
The solution is to update all your packages to [at least] the minor versions accepted on newer MVC (5?). To do so you can use the list in this website: 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-2.
Once everything is up-to-date, open the web.config files located on root of your application and on the Views folder. In there, you will probably find some references to the older versions of MVC and Razor. Update those versions values (all of them) to match the updated versions of your packages (you may create a new empty MVC project on the new Visual Studio and check for those values as a hint of what they should be).
This step is the catch! Since, even if you update you project's packages, some web.config references may still mention the original versions.
Clean the solution (Build > Clean Solution) and close the project. Reopen and compile it. Now [hopefully] everything should be working fine.
[Edit]
One more thing: If your project was also updated from Framework 4.5 to 4.5.1 during this IDE transition, you should also install a NuGet package called "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" (as stated in https://support.microsoft.com/en-us/kb/3025133).

this template attempted to load component assembly Microsoft.VisualStudio.Web.Project

I just installed Visual Studio 2013 Ultimate trial version for completing the MVC5 tutorial by Rick Anderson, which worht doing it.
The tutorial: http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started.
However, I created a blank solution first and then try to add an ASP.Net Application project, which is going to be my MVC5 tutorial project. And I got this weird message:
Error: this template attempted to load component assembly
'Microsoft.VisualStudio.Web.Project, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. For more information on this problem
and how to enable this template, please see documentation on
Customizing Project Templates.
But I´m not customizing, I´m just creating a project out of a built in template.
Do you know how can I solve it?
Here is the solution:
In Visual Studio 2013, select Tools > Extensions and Updates
Check for updates. You should have the Azure SDK update available.
Download and install the Azure SDK. After this, everything should work fine.
If your updates are not turned on, enable your auto detection of updates in Tools > Options > Environment > Extensions.
If you have unspecified error related to E_fail(code), try this:
When creating a new MVC 5 application, change the framework version from 4.5.1 to 4.5, if that did not work change it to 4. Check the below image if it is not clear.
Another approach:
This is really important if you are installing Visual Studio 2013 on un-updated Windows 7.
there reason i am calling out "not updated is",
The reason that 'un-updated' matters is because Visual studio 2013 does not update the powershell that is required by VS2013 for most of the stuff.
The simple solution is to update Powershell to the latest version.
If you are not sure how to update powershell, you can use this tutorial.
So I stumbled upon this issue as well and would like to share how I was able to resolve this problem.
Tools -> Extensions and Updates -> Online -> NGet Package Manager: Click the download button once you have the NGet Package Manager selected. Make sure to restart your Visual Studio after you have downloaded the Manager.
This should do the trick
Close Visual Studio, run the VS executable with the command line option as shown below (you will likely have to supply the full path), and relaunch VS normally. This should re-initialize the templates, including the one that you are having problems with.
devenv.exe /installvstemplates
So I faced the same problem with Visual Studio 2013, and I don't know what's the problem but it appears that it only occurs when creating a new project, and choosing "Web" from the panel.
What I did was simply clicking on "Visual Studio 2012" just below it, and it worked !

Copy and paste Razor markup in Visual Studio 2010 SP1 is extremely slow

Any time I try to paste anything in a CSHTML file that contains Razor markup or targets a line inside a code block - the entire Visual Studio freezes for almost a minute.
I've applied SP1 for Visual Studio. I'm using ASP.NET MVC 3.
I also only have this problem on a single computer so I'm guessing there's some sort of application or version mismatch I'm simply not seeing. I'm running ReSharper and upgraded it to 6.0 to no avail (though the Razor code inspection works and is really nice).
It's only if I paste a line containing Razor markup that the issue occur. I get no errors on the copy operation, and if I'm pasting regular HTML without Razor markup or outside code blocks in the very same file there're no issues whatsoever. No problems pasting in any other kinds of files like .cs or .aspx. Freshly created MVC 3 projects suffer as well as existing old projects.
I resolved this a while ago but I don't recall exactly which component was the issue - but it was either SP1 for Visual Studio that was in fact not RTM (though it wasn't obvious when looking at the about dialog hence the difficulty in figuring out) or, more likely according to my memory, a pre-RTM version of MVC 3 installed, also not obvious at all when looking through the installed components list.
It took some manual work to get all the related components uninstalled, including some registry hacks, before reinstalling the RTM version and then the problem disappeared. I did not have to reinstall Visual Studio or any of my addons.
Hope this helps someone with similar problems, carefully investigate the exact build numbers of the suspected components. They may in fact be pre-RTM :9
Have you tried to reset the Visual Studio settings? I can't promise this will help but I think it would be worth a try (devenv.exe /ResetSettings). If that doesn't help, I think you will have to re-install Visual Studio.

Visual studio closes unexpectedly

I am doing an MVC project... am very new to MVC... something very strange is happening...
When I drop a control from the toolbox to the design page visual studio closes.. I have no clue why this happens.. am totally perplexed...I tried searching for possible solution in the net...nothing showed up...:(
Unless I've totally missed the boat, you shouldn't be able to drag-and-drop any control from the toolbox to an MVC view. At least in MVC 1.0, views and user controls do not implement code-behind by default, but, more importantly, the designer code file that gets modified in WinForms .ASPXs and .ASCXs is not created when the view is created. In MVC, controls are added to views using code-based HTML helpers or the actual HTML code. The fact that the default Visual Studio behavior when executing a drag-and-drop with a toolbox control is to modify the form's designer file could be causing the immediate exit, since the file doesn't exist.
P.S. Don't bother trying to create it...the framework isn't built to implement or support it and it would probably just slow you down, anyway.
Try to start Visual Studio in safemode via
cd C:\Program files\Microsoft Visual Studio 9.0\Common7\IDE
devenv.exe /safemode /log
If this works then one of the installed add ons is responsible for the crash. It often helps in my environment.
Also you may try cleaning up the project.
Run
c:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe yoursolution.sln /t:Clean
Might help if something got screwed in your project.

Resources