When handling a PUT call, a WebAPI handler seems to go into a stack overflow type situation when validating the model. The exception isn't clear, and there is no indication as to what in the model is causing this validation class to go into a loop. Attaching the debugger does nothing. The handler will never get called, the serializer will deserialize the posted json normally without incident. What could be wrong?
The following code just loops several hundred times before exiting throwing the exception"
Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function 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 akin to this simple example. The model has default values which I can confirm are all initialized. The model also has no references to itself.
public class Example {
[Required]
public string test {get; set;}
[Required]
public CustomEnumType myEnum {get; set;}
}