maxItemsInObjectGraph ignored

前端 未结 5 1186
野性不改
野性不改 2021-01-12 09:33

I have a problem with a WCF service, which tries to serialize too much data. From the trace I get an error which says that the maximum number of elements that can be seriali

相关标签:
5条回答
  • 2021-01-12 10:05

    Any setting put in the web.config were happily ignored, I haven't found out why. But I found a workaround, that is, to put the MaxItemsInObjectGraph as a class decoration. This works flawlessly:

    // MyService.svc
    // using...
    
    namespace MyNamespace {
      [ServiceContract]
      [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
      [ServiceBehavior(MaxItemsInObjectGraph = 65536000)]
      public class MyWebService {
    
        [OperationContract]
        [WebGet(UriTemplate = "tree/{sessionId}", ResponseFormat = WebMessageFormat.Json)]
        public MyData GetTree(string sessionId) {
        ...
    ...
    
    0 讨论(0)
  • 2021-01-12 10:05

    From a little search in Google, it seems you are adding the setting in the wrong place.

    You need to create a new behavior in the endPointBehaviors section (not serviceBehaviors).

    0 讨论(0)
  • 2021-01-12 10:07

    I have the same issue. Using service behavior attribute at the class level works fine, which make sense. I prefer config level change. I have added the config entries both at the client(web.config) and service level(app.config). Did this work for you?

    0 讨论(0)
  • 2021-01-12 10:11

    May be it is small yet? did you try to give larger value like 655360000? Note that you should change the value in client's and Server's config files. My guess is that you changed only in one part ;)

    0 讨论(0)
  • 2021-01-12 10:24

    I ran into this as well, in my instance, I had forgot to place this setting in my client app.config file.

    0 讨论(0)
提交回复
热议问题