首页 > 解决方案 > 为什么我在生产 iis 中没有发现 Method not found 异常,但在我的 VS IIS Express 中却没有?

问题描述

在我的 IIS Express 上一切正常,但在生产中我得到一个错误。我该如何解决这个问题?

找不到方法:'System.Collections.ObjectModel.Collection 1 System.Web.Http.HttpConfiguration.get_MessageHandlers()'。源错误:在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。堆栈跟踪:[MissingMethodException:找不到方法:'System.Collections.ObjectModel.Collection 1 configurationCallback) +46 CDW.WebApiApplication.Application_Start() in L:\W\Global.asax.cs:17 [HttpException (0x80004005): Method未找到:'System.Collections.ObjectModel.Collection 1 System.Web.Http.HttpConfiguration.get_MessageHandlers()'。] System.Web.HttpRuntime。1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'.
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.MissingMethodException: Method not found: 'System.Collections.ObjectModel.Collection
1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'.]
CDW.WebApiConfig.Register(HttpConfiguration config) in L:\W\App_Start\WebApiConfig.cs:25
System.Web.Http.GlobalConfiguration.Configure(Action

1<System.Net.Http.DelegatingHandler> System.Web.Http.HttpConfiguration.get_MessageHandlers()'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +517
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +185
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369 [HttpException (0x80004005): Method not found: 'System.Collections.ObjectModel.Collection


System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+714

版本信息:

标签: c#.netiis

解决方案


我有同样的问题。我通过在webconfig.

<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>

推荐阅读