剃刀2剃刀3 MVC 5 [英] Razor 2 to Razor 3 MVC 5

查看:102
本文介绍了剃刀2剃刀3 MVC 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直工作在一个MVC 4解决方案,我一直在试图将它升级到MVC 5.我已经按照<列出的步骤href=\"http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2\">here.

I've been working on an MVC 4 solution, and I've been trying to upgrade it to MVC 5. I've followed the steps outlined here.

我跟着它,而现在每当我运行MVC应用程序,它给了我这个错误消息:

I've followed it, and now whenever I run the MVC Application, it gives me this error message:

[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\User\AppData\Local\Temp\Temporary ASP.NET 
Files\root\665ac028\de53a189\assembly\dl3\c2c0a4b5\56e8099e_40e0ce01\System.Web.WebPages.Razor.dll'.

有谁知道这是如何起源?或者它如何可以解决?迄今为止,我已经看了看四周?我试着改变web.config文件中,有没有效果...

Does anyone know how this could have originated? or how it can be solved? I've looked around thus far? I've tried changing the web.config files, with no avail...

推荐答案

在你的的Web.config ( - S)确保 assemblyBinding 包含装配正确的版本 System.Web.WebPages.Razor System.Web.Mvc

In your Web.config(-s) make sure assemblyBinding contains the proper version for the assembly System.Web.WebPages.Razor and System.Web.Mvc.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
  </dependentAssembly>

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

和确保剃​​须刀 sectionGroup ConfigSections 引用最新版本,以及:

And make sure that razor sectionGroup in ConfigSections reference latest versions as well:

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

这篇关于剃刀2剃刀3 MVC 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆