c# - 为什么我在生产 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.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(Action1<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
版本信息:
Microsoft .NET 框架版本:4.0.30319;
ASP.NET 版本:4.7.3282.0
解决方案
我有同样的问题。我通过在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>
推荐阅读
- python - 如何为两个 for 循环创建两列
- odoo - 日记帐上没有定义默认借方和贷方账户 - Odoo v13
- android - Android Gradle 问题缩小启用 true
- python - 如何将函数的返回值保存到文件中
- php - 考试表格摘要中的模块更改
- ios - 如何为 enom 值输入变量?
- node.js - 尽管在 Mac 上工作,但在 Windows 上的 node.js ENOTFOUND
- laravel - 如何在 Laravel 8.0x 中调用资源控制器
- java - 高斯分布函数对程序和数学的不同答案
- java - Spark Java:向量汇编器的列名中的转义点