我在个人桌面上使用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
我可以知道我的错误在哪里
答案 0 :(得分:0)
简单地说,您尚未部署必要的程序集引用以正确地在主机上工作!它试图搜索,也许在主机提供商系统上,而无法访问!关注these steps以确保您因部署而添加了所需文件。
修改强> 因此,虽然此选项(添加可部署的依赖项)仍然存在于Visual Studio 2010(和Visual Studio 2010 SP1)中,但它与Visual Studio 2012一起内置到NuGet包管理器中,因此所有必需的程序集都会自动进行bin部署。
答案 1 :(得分:0)
在这种情况下,您缺少的特定程序集是 Web API 2.1 WebHost(或现在2.2)。只需使用Nuget Package Console将其添加到项目中,然后重建即可。
答案 2 :(得分:0)
尝试使用Nuget Package Manager将Web API 2.1 WebHost添加到项目中,然后在IIS上重建,发布和部署。
答案 3 :(得分:0)
您可以通过以下任一步骤进行修复:
选项1:要解决此问题,您必须将“ bin”文件夹中的“ System.Web.Http.WebHost.dll”文件移动到IIS。并重新启动服务器以重新加载所有内容。检查网站是否可以正常工作。
选项2:请按照以下步骤操作:
1)转到Visula Studio中的“解决方案资源管理器”。
2)右键单击“参考”中的“ System.Web.Http.WebHost”,然后选择属性。
3)将属性“本地副本”更新为“真”。
4)清除并再次构建以在bin文件夹中具有DLL。
5)将“ bin”文件夹中的“ System.Web.Http.WebHost.dll”文件复制到IIS。
应用程序应该可以工作。
来源:http://sforsuresh.in/not-load-file-assembly-system-web-http-webhost/