2011-11-13 24 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) –