Byte[]/stream through namedPipe WCF is faulted

I am developping a namedpipe Duplex WCF service.

For the basic things, the client and the server are communicating without issue. The server can callback the client sending him strings, and it does it without any issue. But, when i want it to send a bitmap with byte[] or stream, everything is faulting. Just note i tried to use the stream because the byte[] is not working... In server side, the byte[]/stream is generated without issue. But when the server sends the byte[]/stream to the client,if the byte[]/stream is empty it goes through but when it has data it is faulting.

I already checked all my configurations, and tried to set a large buffer/message/poolsize/stringcontent/arraylenght/byteperread/whatever size/lenght because i know that's a classic issue in WCF.

Here is a C/P of the main part of my WCF Config file.

<?xml version="1.0" encoding="utf-8"?>
    <compilation debug="true"/>
        <binding name="NamedPipeBinding_ICameraService" closeTimeout="00:05:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" maxConnections="10" maxBufferPoolSize="500000000" maxBufferSize="500000000" maxReceivedMessageSize="500000000">
          <readerQuotas maxDepth="32" maxStringContentLength="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000"/>
          <security mode="Transport"/>
      <service name="EOSDigital.CameraService" behaviorConfiguration="MEX">
        <endpoint address="net.pipe://localhost/EOSDigital/CameraService" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding_ICameraService" contract="EOSDigital.ICameraService"/>

        <endpoint address="net.pipe://localhost/EOSDigital/CameraService/mex" binding="mexNamedPipeBinding" contract="IMetadataExchange"/>
        <behavior name="MEX">
          <serviceMetadata httpGetEnabled="False"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

Here is the service callback contract

public interface ICameraServiceCallBack
    [OperationContract(IsOneWay = true)]
    void CallBackFunction(string str);

    [OperationContract(IsOneWay = true)]
    void LiveviewUpdated(byte[] img);

And here is the declaration of my Service contract.

[ServiceContract(CallbackContract = typeof(ICameraServiceCallBack))]
public interface ICameraService

I wont put everything, this is too huge.

This is how i use it

private void CurrentCamera_LiveViewUpdated(object sender, Stream img)
    MemoryStream data = new MemoryStream();

    _callback = OperationContext.Current.GetCallbackChannel<ICameraServiceCallBack>();

    _callback.CallBackFunction("this is a test"); // ok

    _callback.LiveviewUpdated(data.ToArray()); //Faulted

I get the Stream from a Canon digital Camera and it is around byte[146242]. When i send a byte[10] it works. It has to be a problem of size, and I guess i missed something in the config file ...

I also tried to generate and take a look to the scvclog file of my service to see some details of the occurring faulted exception. But, well... There is not less than 50k characters in one line. This is not readable.

Thank you.


Check your client WCF configuration. Your client configuration must have the same netNamedPipeBinding as your host.

Put that in your client config file

  <binding name ="duplexEndpoint" closeTimeout="00:05:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="50000000" maxBufferSize="50000000" maxConnections="10" maxReceivedMessageSize="50000000">
    <readerQuotas maxDepth="32" maxStringContentLength="50000000" maxArrayLength="50000000" maxBytesPerRead="50000000" maxNameTableCharCount="50000000"/>

This have to be put bellow the serviceModel.Bindings bracket.

Then, bind the configuration in your endpoint bracket


That should do what you expected.

Need Your Help

Drawing a GPUImage over another one with multiply and alpha

ios gpuimage

I am trying to overlay one image on top of another image with an alpha and multiply blend using GPUImage. In Core Graphics here is what I was doing.