Monday, January 16, 2017

MVC 4 Rajor - [A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection

Hello guys,

I was doing a MVC project for one of my client and received following error when i updated my MVC version from Library Package Manager > Manage NuGet Packages for Solutions...

[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=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\1779caca\ec838677\assembly\dl3\3dd21433\efc909b6_6889d201\System.Web.WebPages.Razor.dll'.

 This weird error was making me crazy. After lot of search on internet i found some article specifying the error caused by version. You can clearly make out from above error its true.

I found out that of Web.config resides inside the View folder of my project was referring to version 2.0.0.0. I have just changed the all versions from 2.0.0.0 to 3.0.0.0 in following section






Hola!!!!!!!!!!!!!!!!

Error gone...





No comments: