'/'应用程序中的服务器错误。在asp.net上

时间:2014-03-20 13:48:15

标签: asp.net-mvc-4

处理nopcommerce主题时出现此错误

[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:\Users\Designer_2\AppData\Local\Temp\Temporary ASP.NET Files\root

\c152d41b\a654685e\assembly\dl3\d2c346c5\cbf4b46b_e2d3ce01\System.Web.WebPages.Razor.dll'.

请告知如何解决?

1 个答案:

答案 0 :(得分:1)

确保您的应用程序根目录web.configViews文件夹中引用了您在项目中引用的相同版本的Razor,类似于以下内容:

<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>