I am using AddXmlDataContractSerializerFormatters to Serialize the data in XML as an output stream but getting the following issue again and again though it works fine with JSON
Here are my setup classes:
class ADto
{
public string Name { get; set; }
public ICollection<BDto> BDtos { get; set; } = null;
}
class BDto
{
public string Description{ get; set; }
}
[Route("api/[controller]")]
[ApiController]
public class AController : ControllerBase
{
public async Task<IActionResult> GetAs()
{
// some logic
}
}
Error "Message": "An unexpected fault happened. Try again later.\nError:Type 'System.Collections.Generic.List`1[[....Models.Dtos.BDto, ....API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'ArrayOfBDto:http://schemas.datacontract.org/2004/07/....API.Models.Dtos' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer."