question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there only one instance of the JsonExceptionFilterAttribute?

See original GitHub issue

“Collection was modified; enumeration operation may not execute.”

https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.AspNet.WebApi/JsonExceptionFilterAttribute.cs#L108

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.List1.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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RicoSutercommented, Jul 3, 2019

Created a PR which fixes this for me: https://github.com/RicoSuter/NSwag/pull/2292

0reactions
kwbontecommented, Jul 3, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - AuthorizationHandler exception not going through ...
Hello I am using " var ex = context.Features.Get<IExceptionHandlerFeature>(); to get the stack trace and inner exception but it is showing null ...
Read more >
net mvc api 配置NSwag 原创
Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to. // hold additional metadata for an API.
Read more >
return custom error from JsonResult to jQuery ajax ...
Retrieve custom information about the error on the client. Here is a basic version of my code: Controller JsonResult method. public JsonResult DoStuff(string ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found