【问题标题】:Silverlight error when loading many rows from SQL database从 SQL 数据库加载多行时出现 Silverlight 错误
【发布时间】:2011-11-11 13:49:10
【问题描述】:

我有一个使用 Entity Framework 4 构建的 Silverlight 应用程序、一堆 Silverlight 模块和一个包含我的 DomainService、Model 和 Web.Config 的 Web 项目。

我从本地 SQL Server 提取数据工作正常。我的一个 SL 模块从特定表中提取数据,当我在此表中有超过 4000 行时,应用程序崩溃并给我以下错误消息。当它有大约 1000 个鱼卵时,它工作得很好。 所以,我想也许 DomainService 不能处理所有的行,或者我在 webconfig 中的绑定设置在某种程度上是错误的。我该怎么办?

错误信息:

{System.ServiceModel.DomainServices.Client.DomainOperationException:查询“LoadSiteCageData”的加载操作失败。远程服务器返回错误:NotFound。 ---> System.ServiceModel.CommunicationException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。 ---> System.Net.WebException:远程服务器返回错误:NotFound。 在 System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) 在 System.Net.Browser.BrowserHttpWebRequest.c_DisplayClass5.b_4(对象 sendState) 在 System.Net.Browser.AsyncHelper.c_DisplayClass4.b_0(对象 sendState) --- 内部异常堆栈跟踪结束 --- 在 System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,对象状态) 在 System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult 结果) --- 内部异常堆栈跟踪结束 --- 在 System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult) 在 System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult) 在 System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) --- 内部异常堆栈跟踪结束 --- 在 System.ServiceModel.DomainServices.Client.OperationBase.Complete(异常错误) 在 System.ServiceModel.DomainServices.Client.LoadOperation.Complete(异常错误) 在 System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) 在 System.ServiceModel.DomainServices.Client.DomainContext.c_DisplayClass1b.b_17(Object )

Web.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
    <sectionGroup name="system.serviceModel">
        <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
</configSections>
<appSettings />
    <system.web>

    <httpModules>
                <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
        <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </assemblies>
    </compilation>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">

    </pages>

    <authentication mode="Windows" />

</system.web>
<system.codedom></system.codedom>

<system.webServer>
    <modules>
                <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <customBinding>
            <binding name="MyService.Web.Service1.customBinding0">
                <binaryMessageEncoding />
                <httpTransport />
            </binding>
        </customBinding>
    </bindings>
    <services>
        <service name="MyService.Web.Service1">
            <endpoint address="" binding="customBinding" bindingConfiguration="MyService.Web.Service1.customBinding0" contract="MyService.Web.Service1" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

【问题讨论】:

  • 你能发布你的配置,特别是端点规范吗?默认情况下,消息有大小限制(64kb?)。你需要增加它。
  • 我已将 webconfig 添加到初始帖子中,请帮助 :)

标签: silverlight sql-server-2008 entity-framework domainservices basichttpbinding


【解决方案1】:

我相信这是由于基本httpbinding 可以通过网络传输的数据大小的限制。它是 64k。

有 2 个选项可以解决此问题。

  • 逐页拉取数据
  • 以逗号分隔文件的形式下载数据,解析并显示

我通常做的是将数据下载为zip文件,在客户端解压缩,然后处理如此大量的数据。

【讨论】:

  • 我不能通过分页来做到这一点,因为我正在提取的所有数据都绘制在图表中。所以 Zip 也不是替代品。
  • 您仍然可以分页数据。为此,您需要一次检索 50 条左右的记录。下载所有记录后,您可以将它们绘制到图表中。
  • 我对这些概念还很陌生,所以现在我不清楚我应该怎么做。所以,基本上我正在寻找这个的 qucik 修复 - 如果有某种缓冲区等,我可以增加。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-13
  • 2022-10-21
  • 2011-12-24
  • 1970-01-01
  • 1970-01-01
  • 2021-04-06
相关资源
最近更新 更多