I am trying to add MessageContract to my WCF service, similar to what happens in this question: WCF: using streaming with Message Contracts
There is an exception: The operation 'UploadFile' cannot be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use other types of parameters.
Here are my contracts:
[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; } }
And here is the binding configuration I use in my app.config:
<netTcpBinding> <binding name="TCPConfiguration" maxReceivedMessageSize="67108864" transferMode="Streamed"> <security mode="None" /> </binding> </netTcpBinding>
Now I think that this may have something to do with the type of binding that I use, but I'm not quite sure.
source share