Asp.Net托管问题:无法加载文件或程序集'System.Web.Http,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'

问题描述 投票:1回答:4

我在我的个人桌面上使用Asp.Net MVC4应用程序并尝试通过使用正常的部署过程远程登录到Windows服务器2012和IIS8并最终当我尝试浏览时向我扔了一个服务器错误,如下所示:

Server Error in '/' Application.
--------------------------------------------------------------------------------


Could not load file or assembly 'System.Web.Http, Version=4.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.Http, Version=4.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.Http, Version=4.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.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   MvcApplication1.MvcApplication.Application_Start() +0

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=4.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) +12881540
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

我可以知道我在哪里弄错了

asp.net asp.net-mvc-4 windows-server-2012 iis-8
4个回答
0
投票

简单地说,您尚未部署必要的程序集引用以正确地在主机上工作!它试图搜索,也许在主机提供商系统上,而无法访问!关注these steps以确保您因部署而添加了所需文件。

编辑:因此,虽然此选项(添加可部署的依赖项)仍然存在于Visual Studio 2010(和Visual Studio 2010 SP1)中,但它与Visual Studio 2012一起内置到NuGet包管理器中,因此所有必需的程序集都会自动进行bin部署。


0
投票

在这种情况下,您缺少的特定程序集是Web API 2.1 WebHost(或现在的2.2)。只需使用Nuget Package Console将其添加到项目中,然后重建即可。


0
投票

尝试使用Nuget Package Manager将Web API 2.1 WebHost添加到项目中,然后在IIS上重建,发布和部署。


0
投票

您可以通过以下任一步骤修复: 选项1:要解决问题,您必须将“bin”文件夹中的“System.Web.Http.WebHost.dll”文件移动到IIS。并重新启动服务器以重新加载所有内容。检查网站是否有效。

选项2:遵循以下步骤: 1)转到Visula Studio中的“Solution Explorer”。 2)右键单击“References”中的“System.Web.Http.WebHost”并选择属性。 3)将属性“Local Copy”更新为“True”。 4)再次清除并构建在bin文件夹中有DLL。 5)将“bin”文件夹中的“System.Web.Http.WebHost.dll”文件复制到IIS。 申请应该有效。

资料来源:http://sforsuresh.in/not-load-file-assembly-system-web-http-webhost/

© www.soinside.com 2019 - 2024. All rights reserved.