raf*_*ale 6 c# wcf messagecontract wcf-streaming
我正在尝试将MessageContract添加到我的WCF服务,类似于此问题中的内容:WCF:使用流式传输与消息合同
这是我得到的异常: 无法加载操作"UploadFile",因为它具有System.ServiceModel.Channels.Message类型的参数或返回类型,或具有MessageContractAttribute的类型和不同类型的其他参数.使用System.ServiceModel.Channels.Message或使用MessageContractAttribute类型时,该方法不得使用任何其他类型的参数.
这是我的合同:
[ServiceContract]
public interface IFile
{
[OperationContract]
bool UploadFile(FileUpload upload);
}
[MessageContract]
public class FileUpload
{
[MessageHeader(MustUnderstand = true)]
public int Username { get; set; }
[MessageHeader(MustUnderstand = true)]
public string Filename { get; set; }
[MessageBodyMember(Order = 1)]
public Stream ByteStream { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我在app.config中使用的绑定配置:
<netTcpBinding>
<binding name="TCPConfiguration" maxReceivedMessageSize="67108864" transferMode="Streamed">
<security mode="None" />
</binding>
</netTcpBinding>
Run Code Online (Sandbox Code Playgroud)
现在我想这可能与我正在使用的绑定类型有关,但我不完全确定.