2013-08-01 100 views
1

我已經在WCF服務中定義了一個方法,它接受byte []作爲參數。當我打電話功能它給我一個錯誤 An exception of type 'System.OutOfMemoryException' occurred in System.ServiceModel.ni.dll but was not handled in user codeReference.csWCF服務 - System.OutOfMemoryException問題

這裏是我的代碼

svc.GetDataUsingDataContractCompleted += new EventHandler<GetDataUsingDataContractCompletedEventArgs>(svc_GetDataUsingDataContractCompleted); 
svc.GetDataUsingDataContractAsync(contents, "AllImagesZip.zip"); 

內容爲byte []的對象。我有以下Web.config文件。

<?xml version="1.0"?> 
<configuration> 
<appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
</appSettings> 
<system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" executionTimeout="300" maxRequestLength="409600"/> 
</system.web> 
<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <!--<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:10:00" closeTimeout="00:10:00"> 
     <security mode="None" /> 
    </binding>--> 
    <binding name="basicHttpsBinding" closeTimeout="01:01:00" 
    openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00" 
    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
    maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646" 
    messageEncoding="Mtom" textEncoding="utf-8" transferMode="StreamedRequest" 
    useDefaultWebProxy="true"> 
    <readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646" 
    maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" /> 
    <security mode="None"> 
    <transport clientCredentialType="None" proxyCredentialType="None" 
     realm="" />   
    </security> 
</binding>  
    </basicHttpBinding>  
</bindings> 

<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https"/> 
</protocolMapping>  
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

我主持這項服務在本地IIS 內容對象包含字節。我認爲這個問題是因爲互聯網連接,但我的互聯網連接工作正常。我得到了什麼應該是錯誤?

回答

1

我有一個類似的問題。如果我記得,你必須在你的WCF服務中修改app.xaml文件,並給予更多的maxbytes,maxpool ...類似的東西

我錯了我更新了Web.Config文件,並最大化了以下事情:

maxBufferSize,maxBufferPoolSize等。

看這裏:Large Binary (byte[]) File transfer through WCF

+0

什麼類型的變化,我必須做的app.xaml? –

+0

已更新我的回答 – Cheese

+0

我收到此錯誤「遠程服務器返回了意外響應:(413)請求實體太大。在Silverlight中,即使服務發送了不同的錯誤代碼,也可能會報告404響應代碼。我已更新我的代碼 –