Is there only one instance of the JsonExceptionFilterAttribute?
See original GitHub issue“Collection was modified; enumeration operation may not execute.”
Newtonsoft has seemed to have compatibility issues in other posts so here is my version of newtonsoft and dotnet:
- newtonsoft: 12.0.1
- Microsoft.AspNet.Core : 5.2.3
There seems to be a problem in the JsonExceptionFilterAttribute where when I use it to generate an exception message on the client side it is works, but generates the collection was modified error above.
Here is the console output:
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List1.Enumerator.MoveNextRare() at System.Collections.Generic.List
1.Enumerator.MoveNext()
at NSwag.AspNet.WebApi.JsonExceptionFilterAttribute.CopySettings(JsonSerializerSettings settings)
at NSwag.AspNet.WebApi.JsonExceptionFilterAttribute.OnActionExecuted(HttpActionExecutedContext context)
at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at DaksWeb.Security.AddChallengeOnUnauthorizedResult.<ExecuteAsync>d__9.MoveNext() in D:\daks\Source\Daks\DaksWeb\Security\AddChallengeOnUnauthorizedResult.cs:line 25
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Created a PR which fixes this for me: https://github.com/RicoSuter/NSwag/pull/2292
@RicoSuter I believe the issue you have encountered is not running nuget restore, if you are using visual studio to run this, in the top right there is a search bar, type manage nuget packages, select the first option, there should be a list of packages and a popup option to restore. select restore and run the app. it should start on a 404 error and you have to manually change the url to the specified path above.