我已經構建了一個WCF服務庫,我添加了幾個第三方DLL的引用。這是我的接口運行WCF服務庫時出錯
[ServiceContract]
public interface IService1
{
[OperationContract]
3rdpartyreturntype GetObj(System.Windows.Controls.Control txtcontrol);
}
// Use a data contract as illustrated in the sample below to add composite types to service operations
[DataContract]
public class nclass
{
[DataMember]
public System.Windows.Controls.Control txtcontrol
{
get { return txtcontrol; }
set { txtcontrol = value; }
}
[DataMember]
public 3rdpartyreturntype nobj
{
get { return vuiobj; }
set { vuiobj = value; }
}
[DataMember]
public System.Windows.Input.TouchDevice tchdev
{
get { return tchdev; }
set { tchdev = value; }
}
}
我已經實現了上面的接口。當我運行服務時出現以下錯誤,任何人都可以幫我解決問題嗎?
類型'System.Windows.Input.TouchDevice'不能被序列化。考慮 使用DataContractAttribute屬性標記它,並用DataMemberAttribute屬性標記要序列化其成員的所有 。
你能爲所有3rdpartyreturntype編寫包裝嗎?如果是這樣,那麼可以用'[DataMember]'屬性標記。 –