I was trying to setup a MVC4 project with ASP.NET MVC 4 source code. After I change the project references and Views\web.config file, all the View pages are just can't use Intellisense in the Visual Studio 2012. See below:
But I do can run the ASP.NET MVC website without any problem.
HI DarrelNorton, It doesn't works. After change to your recommandation, the Razor can't run any more. Please check the following error message:
Server Error in '/' Application.
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the
context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
in the context 'Default' at location 'G:\Temporary ASP.NET Files\root\f55ec8f5\e3d2a456\assembly\dl3\051a9d90\dc0c2fdc_c9c0cd01\System.Web.WebPages.Razor.dll'.
This seems to be an issue/bug with Visual Studio. When you try to use a non-GAC MVC(or WebPages) assembly in Views/web.config then VS cshtml intellisense will think that this cshtml file is a cshtml web page(which is maininly used in WebMatrix and it's inherit
from System.Web.WebPages.WebPage) instead of a MVC view which inherit from System.Web.Mvc.WebViewPage. A quick way to resolve this issue is to add these lines in every MVC view,
Update: I was also able to debug your ditto sample solution by following simple steps available at
here.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
I believe I am suffering from this issue, though in an Umbraco site. Umbraco has now added MVC support, but only v3. So I compiled a custom build with MVC4 instead. It works just fine - apart from the intellisense part of things... The frustrating thing
is that I have previously managed to get it working - but I can't remeber exactly what I did, it just suddenly decided to start working.
Member
15 Points
115 Posts
How to debug asp.net mvc 4 source code with Intellisense enabled?
Nov 11, 2012 01:45 PM|Doggy8088|LINK
I was trying to setup a MVC4 project with ASP.NET MVC 4 source code. After I change the project references and Views\web.config file, all the View pages are just can't use Intellisense in the Visual Studio 2012. See below:
But I do can run the ASP.NET MVC website without any problem.
I made a really simple project to descirbe my question. Here is the projects I made to debug with ASP.NET MVC 4 source code:
https://dl.dropbox.com/u/1011445/TempDownload/debug_mvc4_with_src.zip
Here is what I made with my sample project:
1. Download ASP.NET MVC 4 source code from CodePlex.
2. Unzip it to a folder
3. Open Runtime.sln
4. Add a new ASP.NET MVC 4 project from Visual Studio 2012 ASP.NET MVC 4 Basic Project Template named "MvcApplication1"
5. I tried to remove the following references and add it back from current solution's projects:
6. Then change the web.config file under Views folder. Remove all the following text from this file:
7. Then build & run.
This project can be debug & trace & setup breakpoints without any problem, but all the Views just become unable to use Intellisense.
Does anyone can help?
Thanks!
http://blog.miniasp.com/
All-Star
43204 Points
10243 Posts
MVP
Re: How to debug asp.net mvc 4 source code with Intellisense enabled?
Nov 12, 2012 05:42 AM|DarrellNorton|LINK
The Razor configuration sections should still be version 2.0.0.0. Make sure the following are in your web.config:
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
Member
15 Points
115 Posts
Re: How to debug asp.net mvc 4 source code with Intellisense enabled?
Nov 12, 2012 06:38 AM|Doggy8088|LINK
HI DarrelNorton, It doesn't works. After change to your recommandation, the Razor can't run any more. Please check the following error message:
Server Error in '/' Application.
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'G:\Temporary ASP.NET Files\root\f55ec8f5\e3d2a456\assembly\dl3\051a9d90\dc0c2fdc_c9c0cd01\System.Web.WebPages.Razor.dll'.
http://blog.miniasp.com/
Member
15 Points
115 Posts
Re: How to debug asp.net mvc 4 source code with Intellisense enabled?
Nov 12, 2012 03:33 PM|Doggy8088|LINK
This problem is confuse me for a long time. Hope someone could help me, thanks.
http://blog.miniasp.com/
All-Star
33963 Points
8478 Posts
MVP
Re: How to debug asp.net mvc 4 source code with Intellisense enabled?
Nov 23, 2012 01:22 PM|imran_ku07|LINK
Hi Doggy,
This seems to be an issue/bug with Visual Studio. When you try to use a non-GAC MVC(or WebPages) assembly in Views/web.config then VS cshtml intellisense will think that this cshtml file is a cshtml web page(which is maininly used in WebMatrix and it's inherit from System.Web.WebPages.WebPage) instead of a MVC view which inherit from System.Web.Mvc.WebViewPage. A quick way to resolve this issue is to add these lines in every MVC view,
Update: I was also able to debug your ditto sample solution by following simple steps available at here.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
None
0 Points
4 Posts
Re: How to debug asp.net mvc 4 source code with Intellisense enabled?
Nov 23, 2012 05:26 PM|arknu|LINK
I believe I am suffering from this issue, though in an Umbraco site. Umbraco has now added MVC support, but only v3. So I compiled a custom build with MVC4 instead. It works just fine - apart from the intellisense part of things... The frustrating thing is that I have previously managed to get it working - but I can't remeber exactly what I did, it just suddenly decided to start working.