简体   繁体   English

无法加载文件或程序集 'System.Web.Helpers,错误 IIS 8

[英]Could not load file or assembly 'System.Web.Helpers, error on IIS 8

I have a MVC4 web application that works fine on Visual Studio 2012, using the local IIS Express Server.我有一个 MVC4 web 应用程序,它使用本地 IIS Express 服务器在 Visual Studio 2012 上运行良好。 When I publish the application to an IIS 8 web server running on Windows 2012, the initial login page displays correctly.当我将应用程序发布到运行于 Windows 2012 的 IIS 8 web 服务器时,初始登录页面显示正确。 However, using remote debugging, I see that when I check the credentials using the following line:但是,使用远程调试时,我发现当我使用以下行检查凭据时:

if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))

I get the error shown in the figure below:我得到如下图所示的错误: System.Web.Helpers 错误
(source: usf.edu ) (来源: usf.edu

Solution - Copy reference to local 解决方案 - 将引用复制到本地

  1. Right click on reference System.Web.Helpers and select Properties 右键单击引用System.Web.Helpers并选择Properties
  2. Change Copy Local to true. 将Copy Local更改为true。
  3. Build Solution 构建解决方案

好像MVC尚未安装在服务器上。

The System.Web.Helpers.dll is included in the official Nuget package Microsoft.AspNet.WebPages . System.Web.Helpers.dll包含在官方Nuget包Microsoft.AspNet.WebPages中

Install that and the references should be corrected, and the file should be copied to your bin folder. 安装它并且应该更正引用,并且应该将文件复制到bin文件夹。

I was able to resolve this by downloading the Microsoft Web Platform Installer , searching for MVC and installing the "ASP.NET MVC3 (Visual Studio 2010 ) Released 4/11/2011" package. 我能够通过下载Microsoft Web Platform Installer ,搜索MVC并安装“ASP.NET MVC3(Visual Studio 2010)发布的4/11/2011”软件包解决此问题。 Close any Visual Studio instance prior to installing. 安装前关闭所有Visual Studio实例。

Make sure it's looking for the correct version of the file. 确保它正在寻找文件的正确版本。 Mine were incorrect, the web.config file was pointing to later versions than what I had in the project. 我的不正确,web.config文件指向的版本比我在项目中的版本更高。

In the properties I noted the version was 2.0.0.0 so I made it this version in the web.config file 在我注意到的属性中,版本是2.0.0.0所以我在web.config文件中创建了这个版本

在此输入图像描述

Just adding to the existing answers as even I ran into the same error and could not find the the reference in assemblies. 只是添加到现有的答案,因为我遇到了相同的错误,无法在程序集中找到引用。 I will just share what helped me: 我将分享对我有帮助的东西:

Open package Manager from Tools->NuGet Package Manager->Package Manager Console and type: 从Tools-> NuGet Package Manager-> Package Manager Console打开包管理器,然后键入:

PM> Install-Package microsoft-web-helpers

After this System.Web.Helpers will appear under References->Assemblies. 此System.Web.Helpers将出现在References-> Assemblies下。 From there the 'Copy local' property can be changed to True. 从那里'Copy local'属性可以更改为True。

I am running VS 2015Preview and could resolve the issue by installing the latest version of MVC via NuGet. 我正在运行VS 2015Preview,可以通过NuGet安装最新版本的MVC来解决问题。

Just in case anyone is still coming across this one. 以防任何人仍然遇到这个。

I added "Microsoft ASP.NET Razor" using Manage NuGet Packages. 我使用Manage NuGet Packages添加了“Microsoft ASP.NET Razor”。

With Add References, for some reason, I only had System.Web.Helpers 1.0.0 and 2.0.0... but not 3.0.0. 使用Add References,出于某种原因,我只有System.Web.Helpers 1.0.0和2.0.0 ......但不是3.0.0。

我在IIS 8中使用WCF服务时遇到了同样的问题。看看这个解决方案部署ASP.NET ,它对我有用。

maybe something wrong with your Web.config file. 你的Web.config文件可能有问题。 Open the file and find the <runtime></runtime> tag. 打开文件并找到<runtime></runtime>标记。 modify the version of MVC. 修改MVC的版本。 For example, MVC 3 例如,MVC 3

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

After adding the correct version of MVC, the reference to Microsoft Web Helper is added but not of System.Web.Helper. 添加正确版本的MVC后,添加了对Microsoft Web Helper的引用,但未添加对System.Web.Helper的引用。 Add this manually to your references. 手动将其添加到您的参考。

I had this issue and tried all of the same things to try to resolve it none of the answers above fixed this.我遇到了这个问题并尝试了所有相同的方法来尝试解决它上面的答案都没有解决这个问题。 I ended up manually copying the dll file from another project.我最终从另一个项目手动复制了 dll 文件。 Put it in the project/bin folder.将它放在项目/bin 文件夹中。 Several of my extensions had this issue, I'm not sure what caused it.我的几个扩展有这个问题,我不确定是什么原因造成的。 文件添加到 /bin 文件夹

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM