我在 WCF 服务中定义了一个方法,该方法接受 byte [] 作为参数。当我调用函数时,它给出了一个错误
Reference.cs 中的An exception of type 'System.OutOfMemoryException' occurred in System.ServiceModel.ni.dll but was not handled in user code
。
这是我的代码
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 中本地托管此服务。 内容对象包含 17346288 字节。我认为这个问题是因为互联网连接,但我的网络连接工作正常。我得到的应该是什么错误?
答案 0 :(得分:1)
您的数据传输模式设置为缓冲区,尝试缓冲内存中的整个内容。查看此帖子 - WCF HttpTransport: streamed vs buffered TransferMode
答案 1 :(得分:1)
我有类似的问题。如果我记得,你必须修改你的WCF服务中的app.xaml文件,并提供更多的maxbytes,maxpool ...类似的东西
我错误地更新了Web.Config文件并最大化了以下内容:
maxBufferSize,maxBufferPoolSize等。