私は次のオブジェクトを持っています。int、stringなどのスタンドアジェクトオブジェクトを指定するとうまく動作し、カスタムオブジェクトではうまく動作しません。WCFのカスタムオブジェクト
[DataContract(Namespace = "")]
public class StatusLog<TItem>
{
/// <summary>
/// Gets or sets the key.
/// </summary>
/// <value>
/// The key.
/// </value>
[DataMember]
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the action status.
/// </summary>
/// <value>
/// The action status.
/// </value>
[DataMember]
public ActionStatus ActionStatus { get; set; }
/// <summary>
/// Gets or sets the object.
/// </summary>
/// <value>
/// The object.
/// </value>
[DataMember]
public TItem Object { get; set; }
/// <summary>
/// Gets or sets the message.
/// </summary>
/// <value>
/// The message.
/// </value>
[DataMember]
public string Message { get; set; }
}
これは動作します。新しいStatusLog戻り {ID = Guid.NewGuid()、ActionStatus = ActionStatus.Deleted、オブジェクト= Convert.ToInt32(ID)を、メッセージ= "ノードが正常に削除"}。
これは機能しません: 新しいStatusLog {Id = Guid.NewGuid()、ActionStatus = ActionStatus.Created、Object = MyCustomObject};
MyCustomObjectの型もシリアル化属性( '[DataContract]'、 '[DataMember]')でマークされていますか? –
はい、そうです。彼らは両方です。 –