Reputation: 7325
For no particular reason, I started getting this error.
{ "Message": "An error has occurred.", "ExceptionMessage": "Method not found: 'System.Net.Http.HttpRequestMessage System.Web.Http.Filters.HttpActionExecutedContext.get_Request()'.", "ExceptionType": "System.MissingMethodException", "StackTrace": " at Accounting.Api.Attributes.ExceptionHandlingAttribute.OnException(HttpActionExecutedContext context)\r\n at System.Web.Http.Filters.ExceptionFilterAttribute.OnExceptionAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ExceptionFilterAttribute.d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()" }
Targeted framework is 4.6.1.
Funny thing is that this error is happening on production server, but not on development server. I compared environemnt and deployment files, and they look all the same.
What could cause this error? I tried to google it but only similar issue was asked here
Exception not going to ExceptionFilter after referencing Standard lib
but without any relevant solution..
Upvotes: 1
Views: 1104
Reputation: 6528
You can solve this problem by:
<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>
Upvotes: 2
Reputation: 26
I also got this error and the solution was to toggle between the warning in error list there may be an error of assembly conflicts and said recommend putting the assembly redirect in the web.config.
Double click or Press Enter key after selecting the warning and Visual Studio will take care of the rest by adding the assembly redirects to the web.config file.
Upvotes: 0