我快疯了,我已经用这个工作了一天多,仍然不知道为什么它不起作用,
我有一个用于发送流的 MessageContract,但出现以下错误,
不需要输入数据合同名称为“FileStream: http://schemas.datacontract.org/2004/07/System.IO ”的“System.IO.FileStream”。将任何静态未知的类型添加到已知类型列表中 - 例如,通过使用 KnownTypeAttribute 属性或将它们添加到传递给 DataContractSerializer 的已知类型列表中。
[ServiceContract()]
public interface IContentService
{
[OperationContract(), FaultContract(typeof(ContentFault))]
PublishItemResponse PublishFile(PublishFileRequest request);
}
[MessageContract()]
public class PublishFileRequest
{
[MessageHeader()]
public FileInventoryItem Item {get;set;}
[MessageHeader()]
public Request Request {get;set;}
[MessageBodyMember()]
public Stream FileContent {get;set;}
}
[MessageContract()]
public class Request
{
[MessageHeader()]
public Guid AuthorizationToken { get; set; }
[MessageHeader()]
public string CoreVersion { get; set; }
[MessageHeader()]
public string Password { get; set; }
[MessageHeader()]
public DateTime RequestTime { get; set; }
[MessageHeader()]
public string ComponentVersion { get; set; }
[MessageHeader()]
public string UserName { get; set; }
}
[MessageContract()]
[Serializable()]
public class FileInventoryItem : InventoryItemBase
{
public Stream FileContent { get; set;}
}
[MessageContract()]
[KnownType(typeof(FileInventoryItem))]
[KnownType(typeof(FolderInventoryItem))]
[Serializable()]
public abstract class InventoryItemBase
{
public List<string> Errors {get;set;}
public List<string> Warnings {get;set;}
[MessageHeader()]
public StagingAction Action {get;set;}
[MessageHeader()]
public string ContentXml {get;set;}
[MessageHeader()]
public int ItemId {get;set;}
[MessageHeader()]
public ItemType ItemType { {get;set;}
[MessageHeader()]
public string Name {get;set;}
[MessageHeader()]
public int ParentId {get;set;}
[MessageHeader()]
public Guid ParentUniqueId {get;set;}
[MessageHeader()]
public Guid UniqueId {get;set;}
[MessageHeader()]
public Guid Version {get;set;}
}
任何帮助都会被大大占用,