Complex data types in WCF?

后端 未结 14 1013
自闭症患者
自闭症患者 2020-12-12 19:48

I\'ve run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, \'connect

相关标签:
14条回答
  • 2020-12-12 20:17

    did you specify in your service behavior config? it seems like some information is missing in this stacktrace.

    can you grab the exception at server side (e.g. in visual studio debug mode or with a logging library like log4net).

    have you tried calling some other methods (simple helloworld() e.g.) on the same service to be sure that the service configuration itself works? this kind of exceptino could also indicate some serialization problems. what types do you want to send over the wire? do you use KnownType's somewhere?

    0 讨论(0)
  • 2020-12-12 20:20

    Try setting [OperationBehavior()] above your implementation of the interface method.

    0 讨论(0)
  • 2020-12-12 20:20

    Yep, I had the same problem here and it was todo with returning objects that had enum values in it. Changed the DataMember to an int and everything statrted working.

    0 讨论(0)
  • 2020-12-12 20:27

    Add this line into <system.web/>:

    <httpRuntime maxRequestLength="102400" executionTimeout="3600" />
    
    0 讨论(0)
  • 2020-12-12 20:27

    Enums get a DataContract attribute, like any class would, but the enum values aren't supposed to have DataMember attributes on them.

    Change them to EnumMember and you'll stop getting this inscrutable error.

    0 讨论(0)
  • 2020-12-12 20:27

    I have had the same problem too (.Net 3.5). Turns out my base class DataContract was missing a known type. It's unfortunate that the WCF error was not more descriptive.

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