2011-11-13 45 views
1

你好,我有一個問題,上傳文件使用wcf和流媒體。當我在客戶端上從transferMode =「Streamed」切換到「Buffered」時,雖然沒有流式傳輸,但沒有例外。當我將客戶端切換到「流式傳輸」時失敗。我已經連續幾個小時了,只是把所有的尺寸放大了,以免失敗。我似乎無法找到出錯的地方。任何人都可以發現它?上傳WCF中的大文件,使用流模式

我有以下配置的服務:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="GreenWebManagerServiceBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" messageEncoding="Text" textEncoding="utf-8" > 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
      <security mode="None"> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="GreenWebManagerServiceBehavior" name="GreenWebManagerService.ManagerService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:50036/GreenWebManagerService"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="basicHttpBinding" bindingConfiguration="GreenWebManagerServiceBinding" contract="GreenWebManagerService.IGWManagerService"/> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="GreenWebManagerServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

,並具有以下配置的客戶端:

<system.serviceModel> 
      <bindings> 
       <basicHttpBinding> 
        <binding name="BasicHttpBinding_IGWManagerService" closeTimeout="10:01:00" 
         openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" 
         allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
         maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
         messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed" 
         useDefaultWebProxy="true"> 
         <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
         <security mode="None"> 
          <transport clientCredentialType="None" proxyCredentialType="None" 
           realm="" /> 
          <message clientCredentialType="UserName" algorithmSuite="Default" /> 
         </security> 
        </binding> 
       </basicHttpBinding> 
      </bindings> 
      <client> 
       <endpoint address="http://localhost:50036/GWManagerService.svc" 
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGWManagerService" 
        contract="ManagerService.IGWManagerService" name="BasicHttpBinding_IGWManagerService" /> 
      </client> 
     </system.serviceModel> 

我碰到下面的錯誤和堆棧跟蹤,請注意,這些數字是字節讀我寫到控制檯:

A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll 
A first chance exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll 
A first chance exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll 
256 
4352 
69888 
135424 
200960 
266496 
332032 
397568 
463104 
528640 
594176 
659712 
725248 
790784 
856320 
921856 
987392 
1052928 
1118464 
1184000 
1249536 
1315072 
1380608 
1446144 
1511680 
1577216 
1642752 
1708288 
1773824 
1839360 
1904896 
1970432 
2002629 
2002629 
A first chance exception of type 'System.Net.WebException' occurred in System.dll 
A first chance exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll 
A first chance exception of type 'System.ServiceModel.ProtocolException' occurred in mscorlib.dll 
Step into: Stepping over method without symbols 'System.Reflection.TargetInvocationException.TargetInvocationException' 
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll 
Step into: Stepping over method without symbols 'System.RuntimeType.CreateInstanceImpl' 
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll 
Step into: Stepping over method without symbols 'MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance' 
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll 
Step into: Stepping over method without symbols 'System.Windows.Markup.WpfXamlLoader.Load' 

回答

1

您的異常開始爲wpf x aml加載程序異常。

看來您正試圖將數據直接流式傳輸到WPF控件中。這可能是這個問題。

根據您在做什麼,您可以嘗試將數據流式傳輸到客戶端。然後當數據全部結束時,將其綁定到WPF控件。

+0

我的上傳客戶端是WPF客戶端,因此它會打開一個流並將其發送到cassini中託管的WCF服務(.svc) –