当前位置: 首页 > 知识库问答 >
问题:

无法加载文件或程序集System. Web. WebPage. Razor, Version=3.0.0.0或其依赖项之一

养聪
2023-03-14

我在我的应用程序中使用MVC 5,WCF和Unity框架。

当我运行WCF服务时,我收到以下错误:

Server Error in '/' Application.

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

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. 

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace: 


[FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Mvc.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +556
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9882460
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.33440

我已添加System.Web.WebPages。WCF项目中的Razor,版本=3.0.0.0,仍然存在相同的错误。

有人知道如何解决这个错误吗?

共有3个答案

卓宏达
2023-03-14

我遇到了同样的问题,WCF 显示不相关的 MVC 程序集的错误(我在解决方案中有多个使用 System.Web.WebPages.Razor、Version=3.0.0.0 的 MVC 项目)。我在WCF项目中安装了Microsoft.AspNet.WebPages包,运行WCF proj并正常工作。之后,我卸载了所有与Microsoft.AspNet.WebPages相关的软件包。它工作正常。

江恩
2023-03-14

在我的Win10 x64系统上,我在这里遇到了确切的错误(在几个其他缺失的参考错误中)。我的问题是(我相信),是由卸载一些从添加/删除,撕裂了其他dll。

在网上搜索解决方案后,最终对我有用的是这里的答案:https://stackoverflow.com/a/27785999/692124

下载并安装网页版本2

史谦
2023-03-14

确保您的项目以.net 4.5为目标,所有引用都有效,并且web AspNet.WebPages。*位于bin(Release/Debug)文件夹中。

您还可以尝试在包管理器控制台中使用此命令重新安装Microsoft. ASPNet. WebPages nuget包

> Update-Package –reinstall Microsoft.AspNet.WebPages 
 类似资料:
  • 我在我的网站(web应用程序)中使用了Umbraco 4.11.6。我的网站在localhost上运行(在Visual studio 2012和IIS(v7)上测试过),但是当我在互联网上运行时,出现了一个错误。错误是: 程序集加载跟踪:以下信息有助于确定程序集“System.Web”的原因。无法加载“剃刀”。 WRN:程序集绑定日志记录已关闭。若要启用程序集绑定失败日志记录,请设置注册表值 [H

  • 我尝试将两个 ASP.NET Web 项目(一个 Facebook 应用程序和一个机器人)部署到同一个 Azure 网站,但在我部署了它们之后,我收到了: 无法加载文件或程序集“System.Web”。Mvc’或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(HRESULT异常:0x80131040) 我不确定我能做什么,除了从头开始并将两个项目合并成一个项目(不可取)重新发布。到目前为

  • 问题内容: 我正在使用sharepoint2010。我创建了一个简单的可视化Web部件,其中包含一个文本框,并向其中添加了calendarextender。我已添加为参考。但是,当我部署到SharePoint网站时,它给了我以下错误。 “解析器错误”消息: 无法加载文件或程序集“ AjaxControlToolkit”或其依赖项之一。该系统找不到指定的文件。 源错误: 第3行:<%@ Regist

  • 问题内容: 搜索后我尝试过的事情: 在Web.Config中,对旧版本进行绑定: 问题答案: 好的,我想我现在可以开始工作了。我删除了机器上所有不是我可以找到的最新版本的Newtonsoft.Json.dll,确保在NuGet中拥有最新版本,并进行构建,并确保它是bin文件夹中的最新版本,并且我将更改保留在web.config和.csproj中。现在,我遇到另一个错误,因此它必须正在工作。

  • 搜索后我尝试过的事情: > 编辑我的。csproj文件,以确保只有一个Newtonsoft引用 在我的电脑上搜索每一个Newtonsoft。Json。dll并删除每一个非6.0。1版本并删除我的临时文件夹的内容 修复/重新安装Nuget管理器控制台中的包 它在构建时成功,但在访问站点时出错。 编辑 好的,然后我试着像每个nuget软件包一样重新安装,它似乎又添加了newtonsoft的4.5版本。

  • 问题内容: 我想使用selenium,并从http://www.java2s.com/Code/Jar/s/Downloadseleniumremotedriver2350jar.htm下载selenium。当我尝试加载其中一个dll时,出现错误。希望有人可以帮助我。 这是我的系统信息。 这是我的PowerShell信息。 这是我尝试加载dll时遇到的错误。 问题答案: 如果从Internet下载