以编程方式设置 MaxItemsInObjectGraph
我有一个在客户端和服务器端使用 WCF 的应用程序。当我返回大量数据时出现错误:
尝试序列化参数 http://tempuri.org/:GetCurrentDatabaseObjectsResult 时出错。 InnerException 消息是“对象图中可以序列化或反序列化的最大项目数为“65535”。更改对象图或增加 MaxItemsInObjectGraph 配额。 '。请参阅 InnerException 了解更多详细信息。
(最重要的是我必须增加 MaxItemsInObjectGraph)。
我在这里找到这篇文章: 如何设置以编程方式从 Silverlight 应用程序获取 maxItemsInObjectGraph 属性? 但这似乎仅适用于客户端,我需要在服务器上执行此操作。
I've an application using WCF on client and server side. I get errors when I return a large amount of data:
There was an error while trying to serialize parameter http://tempuri.org/:GetCurrentDatabaseObjectsResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65535'. Change the object graph or increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details.
(the main important thing is that I've to increase the MaxItemsInObjectGraph).
I found this article here: How can I set the maxItemsInObjectGraph property programmatically from a Silverlight Application? but it seems this is only for the client side and I need to do this on the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在代码中:
在配置中:
In code:
In configuration:
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/specifying-data-transfer-in-service-contracts#controlling-the-serialization-process< /a>
转到“控制序列化过程”标题(或搜索 maxItemsInObjectGraph)
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/specifying-data-transfer-in-service-contracts#controlling-the-serialization-process
Go down to "Controlling the serialization process" heading (or do a search for the maxItemsInObjectGraph)
您想要在 ServiceBehavior 属性中指定该属性。
You want to specify the property in the ServiceBehavior attribute.