WCF chokes on properties with no “set ”. Any workaround?

后端 未结 9 756
别跟我提以往
别跟我提以往 2020-12-02 11:34

I have some class that I\'m passing as a result of a service method, and that class has a get-only property:

[DataContract]
public class ErrorBase
{
  [DataM         


        
9条回答
  •  悲&欢浪女
    2020-12-02 12:12

    If it's a viable option, then instead of having ErrorBase as the base class, define it as follows:

        public interface IError
        {
            string Message
            {
                [OperationContract]
                get;
    
                // leave unattributed
                set;
            }
        }
    

    Now, even though a setter exists, it's inaccessible to the client via WCF channel, so it's as if it were private.

提交回复
热议问题