Tuesday, September 25, 2018

How to fix Sitecore View Rendering Visual Studio Intellisense issues


While working on a Helix implementation or even regular Sitecore implementation I came across various intellisense issues in Visual Studio. Some of them are descriptive and some of them aren't. Here are few sample errors that you might come across:



  • The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' .
  • The type or namespace name 'xyz' does not exist in the namespace 'System.Web.Mvc'.
  • 'System.Web.Mvc' doesn't contain a definition for Sitecore and no extension method Sitecore accepting first argument of type.....
You should be able to resolve this issue by following one or more of these steps: 


  1. Update your view's Web.config file with Sitecore's Web.config file as below. Make sure to clean and rebuild the solution once done. 
  2. Once you add the config file and if you are still experiencing issues make sure that the referenced dll is added to the solution. For ex: As above error if it complain about System.Web.dll make sure that it's referenced properly by Nuget. 
  3. Make sure that the dll exists in the bin directory. If not set the Copy Local property in Visual Studio for the dll. Specially for Sitecore make sure that Sitecore.Kernel, Sitecore.Mvc, System.Web, System.Web.Mvc, Glass Mapper dlls(if you are using glass) are referred in the solution. 
  4. In VS 2017 when I experienced this issue I resolved it by updating the DotNetCompilerPlatform by adding one more compiler option in the web.config. The default is 1659;1699;1701; I added 1702 as below:
These are few of the common scenarios and solutions which fixed my issues. If you came across a different solution please feel free to share.