Predefined type System.Object is not defined or imported

自古美人都是妖i 提交于 2019-12-04 23:46:16

I had a lot of CSHTML Intellisense issues with MVC 4 in VS 2015 and opted just to upgrade to MVC 5. However, MVC 4 should still work, just not perfectly, according to: Does Visual Studio 2015 support older versions of MVC?.

This is a problem in both VS 2013 and VS 2015. Build output must be set to the default build path in order for Razor intellisense to work in .cshtml files. See this excellent article reproducing the issue and discussing alternatives. http://www.dennisonpro.info/managing-intellisense-in-razor-views-with-mvc-5-using-custom-builds-in-visual-studio-2013/

So the build path must be set to bin\ for MVC projects. If you need your output to go somewehere else, you must create a post-build step that copies the files from bin\ to another location.

Deleting bin and obj folders in all projects of that solution worked for me.

Seems like those were having old files generated by some older version of visual studio, which are not compatible with new version of visual studio.

Managed the issue.. I had the build path set to a "c:...\bin" instead of "\bin". I believe this happened because I don't have any web.config in the root of the project, so VS didn't identify my project as a web project. After I changed the build root and reloaded the project, the errors were gone and intellisense appeared.

Add the reference to the System assembly in the project references:

right click on references -> add reference -> assemblies -> Framework -> System

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!