WCF双工服务 - 序列化异常

时间:2012-07-10 14:14:20

标签: c# wcf serialization nettcpbinding

这是我的客户端类

using System;
using System.Data;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace Main.Communication
{
    public delegate void EventReceivedEventHandler(DataSet InBoxNotifications, bool updateOutBoxFlag);
    public delegate void OpenConnectEventHandler(int spaceId, string accessionNumber, string modality, long assignedCaseId, long originalCaseId);
    [DataContract]
    public class ClientClass : IClient, IDisposable
    {
        public event EventReceivedEventHandler EventReceived;
        public event OpenConnectEventHandler OpenConnectSystem;

        public ClientClass(int userId)
        {
            this.UserId = userId;
            this.Authentication = Guid.NewGuid().ToString();
        }

        private string _authentication;
        [DataMember]
        public string Authentication
        {
            get { return _authentication; }
            set { _authentication = value; }
        }

        private int _userId;
        [DataMember]
        public int UserId
        {
            set { _userId = value; }
            get { return _userId; }
        }

        #region "IClient Members"
        public bool UpdateInDataBox(DataSet InBoxNotifications, bool updateOutBoxFlag)
        {
            if (EventReceived != null) EventReceived(InBoxNotifications, updateOutBoxFlag);
            return true;
        }
        public void OpenReviewPanel(int spaceId, string accessionNumber, string modality, long assignedCaseId, long originalCaseId)
        {
            if (OpenConnectSystem != null) OpenConnectSystem(spaceId, accessionNumber, modality, assignedCaseId, originalCaseId);
        }
        #endregion

        #region IDisposable Members
        public void Dispose()
        {
            ((ICommunicationObject)this).Abort();
        }
        #endregion
    }
}

其中IClientCallback。我正在使用netTcp绑定。将此对象传递给Server方法时,我收到类似这样的错误,

  

尝试序列化参数http://tempuri.org/:observer时出错。 InnerException消息是'Type'Main.Communication.ClientClass',数据协定名称为“CommunicationClient:http://schemas.datacontract.org/2004/07/Main.Communication.ClientClass”,不是预期的。将任何静态未知的类型添加到已知类型列表中 - 例如,通过使用KnownTypeAttribute属性或将它们添加到传递给DataContractSerializer的已知类型列表中。有关详细信息,请参阅InnerException。

0 个答案:

没有答案