WebAPI PUT InsufficientExecutionStackException with type DbGeography

When processing a PUT call, the WebAPI handler seems to go into a type situation when checking the model. The exception is not clear, and there is no indication as to what in the model causes this verification class to be included in the loop. Attaching a debugger does nothing. The handler will never be called, the serializer will deserialize the sent json, usually without incident. What could be wrong?

The following code just loops a few hundred times before exiting the exception exception

There is not enough stack to continue executing the program safely. This may be due to too many functions on the call stack or functions on the stack, using too much stack space.

at System.Runtime.CompilerServices.RuntimeHelpers.EnsureSufficientExecutionStack() at System.Web.Http.Validation.DefaultBodyModelValidator.ValidateNodeAndChildren(ModelMetadata metadata, ValidationContext validationContext, Object container, IEnumerable`1 validators) at System.Web.Http.Validation.DefaultBodyModelValidator.ValidateProperties(ModelMetadata metadata, ValidationContext validationContext) 

The model is similar to this simple example. The model has default values, which I can confirm, all are initialized. The model also has no references to itself.

 public class Example { [Required] public string test {get; set;} [Required] public CustomEnumType myEnum {get; set;} } 
+6
source share
1 answer

Solution found in: Exclude type from model validation (DbGeography example) to throw ExceptionExceptionStackException

One type of this model is DbGeography . By default, the validator by default enters a loop inside this type, listing its properties. The validator should not even be there and it seems a mistake. But the behavior can be overwritten with a custom validation pattern to ignore this type.

+7
source

Source: https://habr.com/ru/post/981096/


All Articles