I\'m refactoring my XML-serialization, and figured I\'d try the DataContractSerializer. Everything runs smoothly, until it needs to serialize this class:
The problem for me was that I was returning the Interface (IIndividual) from my WebAPI controller. When I changed that return type to the Class (Individual) type, this error went away.
Not working:
[HttpGet]
[Route("api/v1/Individual/Get/{id}")]
public IIndividual Get([FromUri]int id)
{
return _individualService.Get(id);
}
Working:
[HttpGet]
[Route("api/v1/Individual/Get/{id}")]
public Individual Get([FromUri]int id)
{
IIndividual individual = _individualService.Get(id);
return individual as Individual;
}