简体   繁体   English

错误:“无法加载文件或程序集System.Web.WebPages.Razor”

[英]Error: “Could not load file or assembly System.Web.WebPages.Razor”

Suddenly this problem has cropped up for no reason that I can understand. 突然,这个问题突然出现了,我无法理解。

My MVC application makes a call to a WCF Service. 我的MVC应用程序调用了WCF服务。 At that point it hits this exception. 那时它碰到了这个异常。 This was working yesterday. 昨天在工作。 I can't think of anything relevant that changed, although it must be something. 我想不出任何相关的变化,尽管它一定是某些东西。 I can go back to previously working versions of this application, and now the error occurs. 我可以返回到该应用程序的先前工作版本,现在出现错误。

Why is WebPages.Razor getting involved when trying to make a call to a WCF service? 为什么在尝试调用WCF服务时会涉及WebPages.Razor? If I look at my References, there is a reference to System.Web.WebPages.Razor, and the location is valid. 如果我查看我的引用,则有对System.Web.WebPages.Razor的引用,并且该位置有效。 It looks like this DLL is managed by the Microsoft.AspNet.WebPages nuget package ... why is it messed up? 似乎此DLL是由Microsoft.AspNet.WebPages nuget程序包管理的...为什么将其弄乱了? I have version 2.0.20710 of the package installed ... there are various places in web.config that reference System.Web.WebPages.Razor version 2.0.0.0. 我安装了该软件包的2.0.20710版本... web.config中有很多地方引用了System.Web.WebPages.Razor 2.0.0.0版本。

My app crashes today, worked yesterday. 我的应用今天崩溃了,昨天工作了。 Any ideas appreciated... 任何想法表示赞赏...

Here is an example of one of the web.config entries: 这是web.config条目之一的示例:

<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>

Following is the complete error message at the point the exception occurs: 以下是发生异常时的完整错误消息:

System.ServiceModel.ProtocolException: 'The content type text/html; System.ServiceModel.ProtocolException:'内容类型为text / html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). 响应消息的charset = utf-8与绑定的内容类型不匹配(text / xml; charset = utf-8)。 If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. 如果使用自定义编码器,请确保正确实施IsContentTypeSupported方法。 The first 1024 bytes of the response were: ' 响应的前1024个字节为:'

<head>

    <title>Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</title>

    <meta name="viewport" content="width=device-width" />

    <style>

     body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 

     p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}

     b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}

     H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }

     H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }

     pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}

     .marker {font-weight: bold; color: black;text-decoration: none;}

     .version {color: gray;}

     .error {margin-bottom: '.'

************************** update ***************************************** **************************更新*********************** ******************

I've also noticed that I get the same error when I try to Update Service Reference on the WCF web service that is causing the problem. 我还注意到,当我尝试在导致问题的WCF Web服务上更新服务参考时,遇到了相同的错误。 Somehow WebPages.Razor is attempting to load during the update operation, and failing. WebPages.Razor以某种方式尝试在更新操作期间加载,但失败。

The problem was, I have a separate class library to house my WCF services. 问题是,我有一个单独的类库来容纳我的WCF服务。 This library had lost its installation of Microsoft.AspNet.Mvc, Microsoft.AspNet.Razor and Microsoft.AspNet.WebPages. 该库丢失了Microsoft.AspNet.Mvc,Microsoft.AspNet.Razor和Microsoft.AspNet.WebPages的安装。 Once I reinstalled these nuget packages, the problem is resolved. 一旦我重新安装了这些nuget软件包,问题就解决了。 They were already installed in the MVC client, of course. 当然,它们已经安装在MVC客户端中。 The biggest hurdle was that I could not figure out how Razor needed to be involved with my WCF services in a separate library / project from the MVC front-end. 最大的障碍是我无法弄清楚Razor如何需要在MVC前端的单独库/项目中参与WCF服务。 The error was very misleading. 该错误非常令人误解。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行时错误:无法加载文件或程序集“System.Web.WebPages.Razor,版本=3.0.0.0” - Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 无法加载文件或程序集&#39;System.Web.WebPages.Razor,版本= 2.0.0.0,win8 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, win8 无法加载文件或程序集 'System.Web.WebPages.Razor,版本 = 3.0.0.0 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 无法加载文件或程序集 'System.Web.WebPages.Razor,版本 = 1.0.0.0 或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0 or one of its dependencies. The system cannot find the file specified 为什么未加载“ System.Web.WebPages.Razor”程序集? - Why is the 'System.Web.WebPages.Razor' assembly not loading? 无法加载文件或程序集 System.Web.WebPages.Deployment - Could not load file or assembly System.Web.WebPages.Deployment 无法加载文件或程序集“System.Web.WebPages” - Could not load file or assembly 'System.Web.WebPages' 无法读取配置节&#39;system.web.webPages.razor&#39;,因为它缺少节声明 - The configuration section 'system.web.webPages.razor' cannot be read because it is missing a section declaration 在Kentico 8.2升级到9站点后,抛出System.Web.WebPages.Razor版本,Version = 2.0.0.0,例外 - After Kentico Upgrade 8.2 to to 9 site throwing System.Web.WebPages.Razor version , Version=2.0.0.0, exception 尝试引用较新版本的System.Web.WebPages.Razor的MVC4应用程序的问题 - Problems with an MVC4 application trying to reference a newer version of System.Web.WebPages.Razor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM