asp.net-mvc 无法加载文件或程序集“System.Web.Mvc”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/267006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly 'System.Web.Mvc'
提问by Zack Peterson
My new ASP.NET MVC Web Application works on my development workstation, but does not run on my web server...
我的新 ASP.NET MVC Web 应用程序可以在我的开发工作站上运行,但不能在我的 Web 服务器上运行...
Server Error in '/' Application.
“/”应用程序中的服务器错误。
Configuration Error
配置错误
Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
说明:在处理为该请求提供服务所需的配置文件期间发生错误。请查看下面的特定错误详细信息并适当修改您的配置文件。
Parser Error Message:Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
解析器错误消息:无法加载文件或程序集“System.Web.Mvc,版本=1.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件。
Source Error:
源错误:
Line 44: <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 45: <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 46: <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 47: <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 48: <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Source File:C:\inetpub\www.example.org\web.config Line:46
源文件:C:\inetpub\www.example.org\web.config 行:46
Assembly Load Trace:The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
程序集加载跟踪:以下信息有助于确定无法加载程序集“System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”的原因。
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].
Version Information:Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
版本信息:Microsoft .NET Framework 版本:2.0.50727.3053;ASP.NET 版本:2.0.50727.3053
Do I need to install the AspNetMVCBeta-setup.msion the server? Or is there a different installer for servers?
我需要在服务器上安装AspNetMVCBeta-setup.msi吗?或者是否有不同的服务器安装程序?


回答by Haacked
I just wrote a blog post addressing this. You could install ASP.NET MVC on your server OR you can follow the steps here.
我刚刚写了一篇博客文章来解决这个问题。您可以在您的服务器上安装 ASP.NET MVC,或者您可以按照此处的步骤操作。
EDIT:(by jcolebrand) I went through this link, then had the same issue as Victorbelow, so I suggest you also add these:
编辑:(by jcolebrand)我浏览了这个链接,然后遇到了与下面Victor相同的问题,所以我建议你也添加这些:
* Microsoft.Web.Infrastructure
* System.Web.Razor
* System.Web.WebPages.Deployment
* System.Web.WebPages.Razor
回答by Victor Juri
I ran into the same issue as sgriffinusa. In addition to the references Phil's article suggests: http://www.haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx. I added these:
我遇到了与 sgriffinusa 相同的问题。除了参考 Phil 的文章建议:http: //www.haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx。我添加了这些:
* Microsoft.Web.Infrastructure
* System.Web.Razor
* System.Web.WebPages.Deployment
* System.Web.WebPages.Razor
Godaddy Deployment worked perfectly. Turn custom errors off and add references to correct the errors. That should lead you in the right direction.
Godaddy 部署工作完美。关闭自定义错误并添加引用以更正错误。这应该会引导你走向正确的方向。
回答by Matt Rudder
Installing MVC directly on your web server is one option, as then the assemblies will be installed in the GAC. You can also bin deploy the assemblies, which might help keep your server clear of pre-release assemblies until a final release is available.
直接在您的 Web 服务器上安装 MVC 是一种选择,因为这样程序集将安装在 GAC 中。您还可以对程序集进行 bin 部署,这可能有助于在最终版本可用之前让您的服务器远离预发布程序集。
Phil Haack posted a nice article a couple days ago about how to deploy MVC along with your app, so it's not necessary to install directly:
Phil Haack 几天前发表了一篇关于如何将 MVC 与您的应用程序一起部署的好文章,因此没有必要直接安装:
http://www.haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx
http://www.haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx
回答by sgriffinusa
I ran into this same issue trying to deploy my MVC3 Razor web application on GoDaddy shared hosting. There are some additional .dlls that need to be referenced. Details here: http://paulmason.biz/?p=108
我在尝试在 GoDaddy 共享主机上部署我的 MVC3 Razor Web 应用程序时遇到了同样的问题。还有一些额外的 .dll 需要引用。详情请见:http: //paulmason.biz/?p=108
Basically you need to add references to the following in addition to the ones listed in @Haacked's post and set them to deploy locally as described.
基本上,除了@Haacked 的帖子中列出的引用之外,您还需要添加对以下内容的引用,并将它们设置为按照所述在本地部署。
- Microsoft.Web.Infrastructure
- System.Web.Razor
- System.Web.WebPages.Deployment
- System.Web.WebPages.Razor
- 微软网络基础设施
- 系统.Web.Razor
- 系统.Web.网页.部署
- 系统.Web.网页.Razor
回答by warrickh
In VS2010, right click the project in the Solution Explorer and select 'Add Deployable Dependencies'. Then check the MVC related check boxes in the following dialog.
在 VS2010 中,右键单击解决方案资源管理器中的项目并选择“添加可部署依赖项”。然后在下面的对话框中选中 MVC 相关的复选框。
This creates a '_bin_deployableAssemblies' folder in the project which contains all the .dll files mentioned in other answers. I believe these get copied to the bin folder when creating a deployment package.
这会在项目中创建一个“_bin_deployableAssemblies”文件夹,其中包含其他答案中提到的所有 .dll 文件。我相信这些在创建部署包时会被复制到 bin 文件夹中。
回答by Axle
Simple fix. In VS2010, right click on your MVC project, select "Add Deployable Dependencies...", select the the options you want and click ok
简单的修复。在 VS2010 中,右键单击您的 MVC 项目,选择“添加可部署依赖项...”,选择您想要的选项并单击确定
回答by Muhammad Amir
Quick & Simple Solution:I faced this problem with Microsoft.AspNet.Mvc -Version 5.2.3 and after going through all these threads I found a simplest solution.
快速简单的解决方案:我在使用 Microsoft.AspNet.Mvc -Version 5.2.3 时遇到了这个问题,经过所有这些线程后,我找到了一个最简单的解决方案。
Just follow steps:
只需按照以下步骤操作:
- Open NuGet Package Manager in Visual studio for your project
- Search for Microsoft.AspNet.Mvc
- When found, change action to Uninstall and Uninstall it
- Once done, install it again and try it now
- 在 Visual Studio 中为您的项目打开 NuGet 包管理器
- 搜索 Microsoft.AspNet.Mvc
- 找到后,将操作更改为卸载并卸载它
- 完成后,再次安装并立即尝试
This will automatically fix all issues with references. See image below:
这将自动修复所有引用问题。见下图:
回答by Romeo
Had the same issue and added all the assembly that they said but still got the same error.
有同样的问题并添加了他们所说的所有程序集,但仍然出现相同的错误。
turns out you need to make the "Specific Version" = False.
事实证明,您需要使“特定版本”= False。


回答by Dave Shinkle
We want to add it because we are making a class library that uses it.
我们想添加它是因为我们正在制作一个使用它的类库。
For me it is here...
对我来说,它在这里......
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies
回答by Tom Stickel
If your NOT using a hosting provider, and you have access to the server to install ... Then install the MVC 3 update tools, do that... it will save you hours of problems on a windows 2003 server / IIS6 machine. , I commented on this page here Nuget.Core.dll version number mismatch
如果您不使用托管服务提供商,并且您有权访问服务器以进行安装...然后安装 MVC 3 更新工具,请执行此操作...它将为您在 Windows 2003 服务器/IIS6 机器上节省数小时的问题。,我在此页面上评论了 Nuget.Core.dll 版本号不匹配

