While trying to build a web app using .NET Core, I used the Web App template and while everything works exactly as one would expect, the IntelliSense on .cshtml pages is extremely misleading. It doesn't recognize #ViewData, #model, or #Model tags, but when a view model is added or a ViewData message is used, the project compiles and runs as normal. However, IntelliSense marks them red like so...
... and says "Cannot resolve symbol" even when using Microsoft's own .NET Core web application template in a fully updated Visual Studio 2015, will all necessary NuGet packages installed. Does anyone know if this is a bug that needs to be fixed or there's a definitive checklist of NuGet packages to add? Adding various Mvc.Tooling and Tooling.Razer packages only enables tag helpers, but anything other than code after an # on a .cshtml file is still flagged as an error...
[SOLVED] Please see answer...
After deleting everything from C:\Users[me]\AppData\Local\Microsoft\Visual Studio and VSCommon, then running devenv /resetuserdata in the Visual Studio Command Prompt, singing back in, and restoring my environment, the issue resolved itself.
Still not sure whats wrong, but it seems too complex to me to figure out on my own without deeper knowledge of VS 2015...
Related
I downloaded a working MVC project to learn the actual MVC coding. On direct build, it gave me errors, I searched the net and as per suggestions I updated all the nuget packages and the other updates available. Now Razor is updated to 3.0, MVC to 5.2.3.0, Visual Studio to its latest version of VS 2012, and there is no intellisense anywhere on my project. I tried updating the web config with various values as suggested by users. I also tried updating the GUID. I created a fresh MVC 4 project and tried multiple times, but ended up updating the files and eventually back to Step 1. Its a hair pulling story now, as i cannot manage to get intellisense and all my work is stalled. Please help
This might do the trick for you
Tools->Options->Text Editor->C# (or All Languages)->General
and enable Auto List Members and Parameter Information in right hand side pane.
After installing ASP.Net Core via Visual Studio ==> New Project ==> Web ==> ASP.Net Web Application ==> OK ==> ASP.Net 5 Templates. Restarted the system after the installation then create a new project of ASP.NET 5 Template ==> Empty website. I dont get any intellisense and all class names are in RED as if the Visual Studio or Resharper is unable to locate the definition.
Here are some screen shots.
and no intellisense
When using services object, I was expecting services.AddSingleton, service.AddScoped services.AddTransient service.AddLogging and so on...
I have restarted the visual studio but still the same result, however the project compiles and runs as expected but its very difficult to figure out the new api without any support from the intellisense.
I have resharper v 9 with update 1 installed.
Thanks!
I had the same issue with .NET Core and disabling Resharper worked for me. As soon as I disabled it, Intellisense in Razor views started working again.
It all depends what version of ASP.NET 5 you're using, as it's been a bit of a moving target to support. It should work, but for (I think) RC1 bits, but if you're trying to use the current pre-RC2 builds, there are known issues (e.g. the tooling has been completely rewritten). We're hoping to get things fixed and updated post RC2, but with the recent announcements about continuing breaking changes to the tooling (project.json is being phased out and replaced with .csproj files), this might not be so easy. We're going to have to wait and see how the RC2 tooling looks.
After having installed the Update 4, Visual Studio 2013 don't recognize everything related to MVC anymore and a lot of things are underlined in red.
Assemblies such as System.Web.Html.HtmlHelper or System.Web.Mvc are presents in warning messages, but my applications still runs.
The problem is that now, I can't add a new Controller or add a View to a Controller, and this is really problematic when I want for example to generate a Controller with Views using Entity Framework.
I have tried to relaunch the Update4.exe with "Repair" option.
I also have tried to unintsall and reinstall VS2013.
Please answer me if you have a solution.
It sounds like you became a victim of MS14-059 windows update. Make sure that you are referencing correct assemblies not from GAC but these that you downloaded via NuGet.
Am I doing something wrong or is Visual Studio 2013 default projects broken?
Create a new basic MVC project:
File -> New -> Project
and
Templates / Visual C# / Web / ASP.Net Web Application
and
MVC with no Authentication
and immediately on running "template default empty project" I get
Could not load file or assembly 'WebGrease, Version=1.5.1.25624....
Line 5: <meta name="viewport" content="width=device-width, initial-scale=1.0">
Line 6: <title>#ViewBag.Title - My ASP.NET Application</title>
Line 7: #Styles.Render("~/Content/css")
Line 8: #Scripts.Render("~/bundles/modernizr")
Line 9: </head>
and with
Templates / Visual C# / Web / Visual Studio 2012 / ASP.Net Web MVC 4 Application
Razor, Internet Application with a Test Unit
I immediately on starting getting:
Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0...
Well... This is default projects, which makes me wonder why I need to immediately fix anything before even doing anything. It's fun, when you're experimenting needing to try to fix things before you even have begin coding.
This is Visual Studio 2013 Pro with everything installed and these are the "Default New Projects".
Removed the lines causing the exceptions, nothing works. Installed WebGrease, Web.Optimization and DotNetOpenAuth extensions, Bootstrap (since it looked like CSS problems).
Looked like this had the solution but no luck:
Could not load file or assembly 'WebGrease' or one of its dependencies
In short, if I need to fix every project before starting a new project - something must be wrong.
EDIT
Reinstalling and updating everything in the Nuget console makes both error above disappear, but then this happens:
'System.Web.Mvc, Version=5.2.0.0" exception
and then fixing it with Package Manager Console
Install-Package Microsoft.AspNet.Mvc -Version 5.2.0.0
causes the WebGrease error to appear again and the Nuget console wants me the update the MVC again
trying to fix the webgrease error with installing the expected version instead causes this in the Console:
"Install-Package : Updating 'WebGrease 1.6.0' to 'WebGrease 1.5.1' failed."
So for me, it does NOT work out of the box (with VS2013 Update 3 installed) and restarting a new project seems to make all updates disappear and all errors reappear again, having me to redo the whole process even though I've "seemingly" updated everything that I could update. And it's also very obviously not backwards compatible. WebGrease 1.6 will not work for 1.5.1.
I finally managed to fix this but I have no clue as to why it is like it is.
Creating a project on my external device which is also encrypted, where I'm storing most of my project is causing this error.
When I instead moved a project to an internal device, or created one there - it does not happen.
When I also move the project to the root folder of my device, it works also, which means something is wrong with my paths. But I guess that kind of warning would be nicer to get rather than there are lots of assemblies not being able to load. It's kind of the wrong error message. And as far as I can tell, the assemblies would probably be located at the install location and not in my project - so as to why this error happens I have no clue, files should still be accessible.
I noticed that it worked when creating a new Project in the default folders in My Document that it finally worked.
Maybe it's a bug including long folder names, but it's not that deeply located on the External Device. 5 Folder, with about 75 character length in the PATH to the folder where it's in. And I think that it's at least 256 characters before Windows start complaining about length of the "Path".
Well, anyhow. If someone encounters error that are not really errors, check your folders and where it's at. I've had projects lots deeper than this in earlier version of Visual Studio and without complaints and errors.
I reinstalled from Visual Studio 2013 Professional to Visual Studio 2013 for Web with Update 4, and same things happened in both versions. Probably the solution for both then.
I have a console app with a razor view in it. I have included what I understand to be all the references needed. In VS2010 Ultimate, the yellow syntax highlighting and intellisense works. When I open the exact same project on another machine with c# Express, the .cshtml has the 'unknown' icon instead of the cshtml one, and no highlighting/intellisense exists.
I've installed MVC3 on both, as well as downloaded/ referenced as needed:
RazorEngine.dll
System.Web.Razor
Any thoughts?
EDIT: I've now installed Visual Web Developer and then reinstalled MVC3, this has now made 'new MVC 3 project' available and the icon on .cshtml looks like it should. However, still no intellisense.
You will need the WebDeveloper Express (not C# Express). But I'm not sure it handles Console apps.
The designer and template support is split up in the Express versions. So this mixed app might be difficult to get working.