Why can't a DataMember in WCF return Type?

前端 未结 2 1312
温柔的废话
温柔的废话 2021-01-17 14:18

Trying to get this to work, with no luck:

[DataMember]
public Type ParameterType { get; set;}
相关标签:
2条回答
  • 2021-01-17 14:52

    Any field or property that returns System.Type is not serializable using WCF because, at runtime, the actual type of the object is System.RuntimeType, which is marked as internal, and thus cannot be automatically serialized by the DataContractSerializer, which can only serialize publicly accessible types.

    However, you could write an IXmlSerializer wrapper around System.Type that will pull out the information you intend to transfer.

    0 讨论(0)
  • 2021-01-17 14:54

    Web Services, in general, are meant to be cross-platform. What would a Java program do with a System.Type from .NET?

    Also, what part of Type would you like to see serialized, and how would you like to see it deserialized?

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