在 WCF 中反序列化对象时出错 [英] Error while deserializing the object in WCF

查看:48
本文介绍了在 WCF 中反序列化对象时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 WCF 中创建了一个 REST 服务.我面临以下问题

I have created a REST Service in WCF. I am facing the following issue

反序列化 System.Collections.Generic.IList 类型的对象时出错.已超出最大读取深度 (32),因为正在读取的 XML 数据的嵌套级别超过配额允许的级别.可以通过更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxDepth 属性来增加此配额.

There was an error deserializing the object of type System.Collections.Generic.IList. The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota. This quota may be increased by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

我没有在配置中指定任何类型的绑定,因为我已经按照 REST 入门工具包开发了服务.请建议我如何修复它.

I haven't specified any type of binding in configuration since I have developed the service as per REST Starter Kit. Please suggest something as to how can I fix it.

代码有时运行良好,但确实会引发错误.

The code is working fine sometimes but it do throw error.

推荐答案

就我而言,问题是我返回了从数据上下文中获得的实体框架对象.解决方案是在重新调整它们之前分离每个对象.

In my case, the problem was that I was returning Entity Framework objects that I got from the data context. The solution was to detach each object before retuning them.

这篇关于在 WCF 中反序列化对象时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆