我对此完全是绿色的,它让我疯狂 - 它适用于某些数据集但不适用于其他数据集。
编辑:看起来它与记录数量有关 - 不知何故,当记录数量达到一定数量时 - 可能就像250一样 - 当它崩溃时就是这样。似乎涉及到自动递增ID主键,因为我可以看到当我在ID列进入400时添加甚至3条记录但是所有记录都被删除时它仍然产生相同的错误但是当我重置ID时为零 - 可以在XML正文中添加相同的3条记录并进行适当格式化。
映射类型:Int32 - > Byte System.Int32 - > System.Byte目标路径:FixtureDto.ExchangeType.ExchangeType.Id.Id源值:268
对于无符号字节,值太大或太小。
'ObjectContent`1'类型无法序列化内容类型'application / xml的响应主体;字符集= UTF-8' 。
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Mapping types: Int32 -> Byte System.Int32 -> System.Byte Destination path: FixtureDto.ExchangeType.ExchangeType.Id.Id Source value: 268
</ExceptionMessage>
<ExceptionType>AutoMapper.AutoMapperMappingException</ExceptionType>
<StackTrace>
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext() at WriteArrayOfFixtureDtoToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, 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.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Value was either too large or too small for an unsigned byte.
</ExceptionMessage>
<ExceptionType>System.OverflowException</ExceptionType>
<StackTrace>
at System.Convert.ToByte(Int32 value) at System.Int32.System.IConvertible.ToByte(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.ComponentModel.BaseNumberConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType) at AutoMapper.Mappers.TypeConverterMapper.<>c__DisplayClass1_0.<GetConverter>b__0() at AutoMapper.Mappers.TypeConverterMapper.Map(ResolutionContext context, IMappingEngineRunner mapper) at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
</StackTrace>
</InnerException>
</InnerException>
</Error>