我正在開發一個namedpipe雙工WCF服務。字節[] /流通過namedPipe WCF發生故障
對於基本的東西,客戶端和服務器通信沒有問題。服務器可以回送客戶端發送給他的字符串,並且它沒有任何問題。 但是,當我想要它發送一個位圖與字節[]或流,一切都是錯誤的。只是說明我試圖使用流,因爲字節[]不工作... 在服務器端,字節[] /流生成沒有問題。 但是當服務器將byte [] /流發送到客戶端時,如果byte []/stream是空的,它會通過,但是當它有數據時,它是錯誤的。
我已經檢查了所有的配置,並試圖設置一個大緩衝區/消息/ poolsize/stringcontent/arraylenght/byteperread /任何大小/長度,因爲我知道這是WCF中的一個經典問題。
這是我的WCF配置文件的主要部分的C/P。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<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"/>
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<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"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MEX">
<serviceMetadata httpGetEnabled="False"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
這是合同中的服務回調
[ServiceContract]
public interface ICameraServiceCallBack
{
[OperationContract(IsOneWay = true)]
void CallBackFunction(string str);
[OperationContract(IsOneWay = true)]
void LiveviewUpdated(byte[] img);
}
這裏是我的服務合同的聲明。
[ServiceContract(CallbackContract = typeof(ICameraServiceCallBack))]
public interface ICameraService
我不會把所有東西都放進去,這太大了。
這是我如何使用它
private void CurrentCamera_LiveViewUpdated(object sender, Stream img)
{
MemoryStream data = new MemoryStream();
img.CopyTo(data);
_callback = OperationContext.Current.GetCallbackChannel<ICameraServiceCallBack>();
_callback.CallBackFunction("this is a test"); // ok
_callback.LiveviewUpdated(data.ToArray()); //Faulted
}
筆者從佳能數碼相機得到的流,它是圍繞字節[146242]。當我發送一個字節[10]它的作品。 它必須是一個大小的問題,我想我錯過了配置文件中的東西...
我也嘗試生成並看看我的服務的scvclog文件,以查看發生的一些細節錯誤的例外。 但是,呃...在一行中有不少於5萬個字符。這是不可讀的。
謝謝。
謝謝!我不知道我怎麼會錯過這個.... –