【问题标题】:why im getting a Method not found exception into production iis but not in my VS IIS Express?为什么我在生产 iis 中没有发现 Method not found 异常,但在我的 VS IIS Express 中却没有?
【发布时间】:2019-06-09 20:16:01
【问题描述】:

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

找不到方法: 'System.Collections.ObjectModel.Collection1<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.Web.Http.HttpConfiguration.get_MessageHandlers()'。资源 错误:执行过程中产生了未处理的异常 当前的网络请求。有关起源和位置的信息 可以使用异常堆栈跟踪来识别异常 以下。堆栈跟踪:[MissingMethodException:找不到方法: 'System.Collections.ObjectModel.Collection1<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 配置回调)+46
L:\W\Global.asax.cs:17 中的 CDW.WebApiApplication.Application_Start() [HttpException(0x80004005):找不到方法: 'System.Collections.ObjectModel.Collection1<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
1 System.Web.Http.HttpConfiguration.get_MessageHandlers()'。]
System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext 上下文)+714

版本信息:

  • Microsoft .NET Framework 版本:4.0.30319;

  • ASP.NET 版本:4.7.3282.0

【问题讨论】:

  • 要在黑暗中试一试,并说您的所有代码都没有到达您发布的位置吗?
  • 很可能您缺少操作系统中默认的引用,或者您的生产环境 IIS 配置错误。
  • 使用 Microsoft 的“程序集绑定日志查看器”(Fuslogvw.exe) 确保您没有缺少程序集。 docs.microsoft.com/en-us/dotnet/framework/tools/…

标签: c# .net iis


【解决方案1】:

我遇到了同样的问题。我通过在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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-28
    • 2015-05-26
    • 1970-01-01
    • 2010-10-15
    • 2017-06-16
    • 2021-09-14
    相关资源
    最近更新 更多