现场停在asp.net System.Web.WebPages.Razor.Configuration.HostSection工作不能被转换为 [英] Site stopped working in asp.net System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to

查看:187
本文介绍了现场停在asp.net System.Web.WebPages.Razor.Configuration.HostSection工作不能被转换为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对服务器这样的问题。

I have a problem like this on server

[A] System.Web.WebPages.Razor.Configuration.HostSection不能投
  为[B] System.Web.WebPages.Razor.Configuration.HostSection。 A型
  从System.Web.WebPages.Razor,版本= 2.0.0.0起源,
  文化=中性公钥= 31bf3856ad364e35'的背景下,
  默认的位置
  'C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Web.WebPages.Razor\\v4.0_2.0.0.0__31bf3856ad364e35\\System.Web.WebPages.Razor.dll'.
  B型从'System.Web.WebPages.Razor,版本= 1.0.0.0起源,
  文化=中性公钥= 31bf3856ad364e35'的背景下,
  默认的位置
  'C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Web.WebPages.Razor\\v4.0_1.0.0.0__31bf3856ad364e35\\System.Web.WebPages.Razor.dll'.

[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=1.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_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.

说明:在当前Web请求的执行过程中发生未处理的异常。请查看有关错误的详细信息的堆栈跟踪以及它起源于code。

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.InvalidCastException:
  [A] System.Web.WebPages.Razor.Configuration.HostSection不能投
  为[B] System.Web.WebPages.Razor.Configuration.HostSection。 A型
  从System.Web.WebPages.Razor,版本= 2.0.0.0起源,
  文化=中性公钥= 31bf3856ad364e35'的背景下,
  默认的位置
  'C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Web.WebPages.Razor\\v4.0_2.0.0.0__31bf3856ad364e35\\System.Web.WebPages.Razor.dll'.
  B型从'System.Web.WebPages.Razor,版本= 1.0.0.0起源,
  文化=中性公钥= 31bf3856ad364e35'的背景下,
  默认的位置
  'C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Web.WebPages.Razor\\v4.0_1.0.0.0__31bf3856ad364e35\\System.Web.WebPages.Razor.dll'.

Exception Details: System.InvalidCastException: [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=1.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_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.

源错误:

我已经安装了MVC 3塞雷尔语和我的电脑上。我曾尝试与15日龄codeBase的,但同样的问题,取代它存在了。

I have installed MVC 3 on serer and on my computer. I have tried with replacing it with 15 days old codebase but the same problem exist.

现在我要解决它。难道有人知道我怎么能解决这个问题。

now I want to solve it. Do someone know how I can fix it.

推荐答案

在根Web.config确保assemblyBinding包含正确的版本为大会System.Web.WebPages.Razor和System.Web.Mvc 。检查他们的实际存在,以及我的System.Web.WebPages.Razor集结号标签缺失导致错误。我有我的程序集版本在写这篇文章以饱满的NuGet更新的时间分别为3.0和5.0。 code看起来应该像下面。该公钥将保持版本之间的相同。干杯!

In the root Web.config make sure assemblyBinding contains the proper version for the assembly "System.Web.WebPages.Razor" and "System.Web.Mvc". Check for their actual existence as well as my "System.Web.WebPages.Razor" assembly tag was missing causing the error. I had my assembly versions set to 3.0 and 5.0 respectively in the time of this writing with full NuGet updates. Code should look something like below. The publicKeyToken will stay the same between the versions. Cheers!

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <!--some more bidings-->
  <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>
<!--some more bidings-->
</assemblyBinding>

这篇关于现场停在asp.net System.Web.WebPages.Razor.Configuration.HostSection工作不能被转换为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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