wcf中的OutOfMemoryException

时间:2014-10-24 06:12:40

标签: vb.net wcf

我是宽带网络服务的新手我有想要从SQL 2005数据库中提取10000条记录的Windows Mobile 5应用程序。每次单击同步按钮时,我都会收到OutOfMemoryException。他在网络配置中需要做什么才能防止出现此错误? 我的代码

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>

      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" />
    <httpRuntime maxRequestLength="1572864"/>
  </system.web>
 <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
  </runtime>
   <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>

      <service name="WcfServiceLibrary1.LocalDataCache1SyncService" behaviorConfiguration="WcfServiceLibrary1.LocalDataCache1SyncServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress ="http://fo me to know/LocalDataCache1SyncService/"/>
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="basicHttpBinding" contract="WcfServiceLibrary1.ILocalDataCache1SyncContract"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary1.LocalDataCache1SyncServiceBehavior">
                    <serviceMetadata httpGetEnabled="True" />
                    <serviceDebug includeExceptionDetailInFaults="True" />
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

 <system.diagnostics>
      <sources>
            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="traceListener" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "c:\log\Traces.svclog" />
            </listeners>
         </source>
      </sources>
   </system.diagnostics>
</configuration>

1 个答案:

答案 0 :(得分:0)

我的问题是修复。请参阅更新的we.config。我的Windows移动设备有4G存储,服务器1T有10G内存。

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="CPXZMobileAssistantServer.My.MySettings.ServerCPXZMobile2005_Data1ConnectionString"
      connectionString="Your Data Source"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" />
  </system.web>
    <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true" />
    </diagnostics>
    <bindings>
      <basicHttpBinding>
        <binding name="WindowsSecured" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
                      maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CPXZMobileAssistantServer.LocalDataCache1SyncServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="CPXZMobileAssistantServer.LocalDataCache1SyncServiceBehavior"
              name="CPXZMobileAssistantServer.LocalDataCache1SyncService">
        <endpoint binding="basicHttpBinding" bindingConfiguration="WindowsSecured" bindingName="" contract="CPXZMobileAssistantServer.ILocalDataCache1SyncContract" />
        <endpoint address="mex" binding="mexHttpBinding" bindingName="" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://cpxzpos.com" />
          </baseAddresses>
        </host>
      </service>
    </services>

  </system.serviceModel>

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
        <listeners>
          <add name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData="c:\log\Traces.svclog"  />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

</configuration>