第三方DLL的WCF错误

时间:2014-11-27 17:18:18

标签: c# wcf

我是WCF的新手,面临一些问题。我有三个项目WCFClientWCFServiceCommonModel

  1. CommonModel: - 有以下课程 public class Room: INotifyPropertyChanged { int roomID; public virtual int roomID_PK { get; set; } public Room() { Row1Details = new RoomRowDetails(); Row2Details = new RoomRowDetails(); } }

    [Serializable] public class RoomRowDetails : ISerializable, INotifyPropertyChanged { public RoomRowDetails() { RoomColor = "White"; RowSaleAmount = ""; } .... }

  2. WCFClient:正在使用客户端代理类。
  3. WCFServiceServiceContract OperationContract DataContract并且有以下课程: -

    [DataContract()]
    [ServiceKnownType(typeof(Room))]
    [ServiceKnownType(typeof(RoomRowDetails))]
    public class RequestData
        {
    
        [DataMember]
        public string ClientName { get; set; }
    
        [DataMember]
        public bool isServer { get; set; }
    
        [DataMember]
        public bool isSuccess { get; set; }
    
        [DataMember]
        public Room room { get; set; }
    
        [DataMember]
        public RoomRowDetails roomrow{ get; set; }
        }
    
  4. 在项目中添加CommandModel项目作为参考。客户端代理生成正确但在运行项目时。我得到以下错误: -

    There was an error while trying to serialize parameter http://tempuri.org/:eventData. The InnerException message was 'Type 'CommonModel.MODELS.Room' with data contract name 'Room:http://schemas.datacontract.org/2004/07/CommonModel.MODELS' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.

    您能帮我解决一下如何在CommonModel服务和客户端中使用WCF课程(So Room是项目之间的共享POCO)并避免上述错误吗?

    谢谢

0 个答案:

没有答案