在maxItemsInObjectGraph属性通过从Silverlight应用程序如何我设置? [英] How can I set the maxItemsInObjectGraph property programmatically from a Silverlight Application?

查看:203
本文介绍了在maxItemsInObjectGraph属性通过从Silverlight应用程序如何我设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用WCF服务与数据库进行通信的Silverlight 3.0的应用程序,当我从服务方法返回大量的数据,我得到的服务未找到错误。我相当有信心,要解决它是简单地更新maxItemsInObjectGraph属性,但我创建了服务客户端progrogrammatically,找不到在哪里设置该属性。下面是我在做什么现在:

  basicHttpBinding的约束力=新basicHttpBinding的(BasicHttpSecurityMode.None)
{
    MaxReceivedMessageSize = int.MaxValue,
    MaxBufferSize = int.MaxValue
};

MyService.MyServiceServiceClient客户=新MyService.MyServiceProxyServiceClient(结合,新的EndpointAddress(新的URI(Application.Current.Host.Source../MyService.svc)));
 

解决方案

这不是在绑定定义,但在服务的行为。

在Silveright,maxItemsInObjectGraph默认为int.MaxValue。

下面是一个关于如何去改变它的.NET应用程序的文章,而不是Silverlight的:<一href="http://geekswithblogs.net/RandyMichak/archive/2009/03/04/programattically-setting-the-maxitemsinobjectgraph-property-in-client.aspx">Programattically设置MaxItemsInObjectGraph属性客户端

的code代码片段:

 保护ISecurityAdministrationService GetSecAdminClient()
{
     的ChannelFactory&LT; ISecurityAdministrationService&GT;厂=新的ChannelFactory&LT; ISecurityAdministrationService&GT;(wsSecAdminBinding,SecAdminEndpointAddress);
     的foreach(OperationDescription运在factory.Endpoint.Contract.Operations)
     {
       DataContractSerializerOperationBehavior dataContractBehavior = op.Behaviors.Find&其中; DataContractSerializerOperationBehavior&GT;()作为DataContractSerializerOperationBehavior;
       如果(dataContractBehavior!= NULL)
       {
             dataContractBehavior.MaxItemsInObjectGraph = 2147483647;
       }
     }
    ISecurityAdministrationService客户= factory.CreateChannel();
    返回客户端;
}
 

I have a Silverlight 3.0 application that is using a WCF service to communicate with the database, and when I have large amounts of data being returned from the service methods I get Service Not Found errors. I am fairly confident that the solution to it is to simply update the maxItemsInObjectGraph property, but I am creating the service client progrogrammatically and cannot find where to set this property. Here is what I am doing right now:

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
{
    MaxReceivedMessageSize = int.MaxValue,                  
    MaxBufferSize = int.MaxValue
};                        

MyService.MyServiceServiceClient client = new MyService.MyServiceProxyServiceClient(binding, new EndpointAddress(new Uri(Application.Current.Host.Source, "../MyService.svc")));

解决方案

It's not defined in binding, but in Service Behavior.

In Silveright, maxItemsInObjectGraph defaults to int.MaxValue.

Here is an article on how to change it for .NET application, but not Silverlight: Programattically setting the MaxItemsInObjectGraph property in client

A snippet of the code:

protected ISecurityAdministrationService GetSecAdminClient()
{
     ChannelFactory<ISecurityAdministrationService> factory = new    ChannelFactory<ISecurityAdministrationService>(wsSecAdminBinding, SecAdminEndpointAddress);
     foreach (OperationDescription op in factory.Endpoint.Contract.Operations)
     {
       DataContractSerializerOperationBehavior dataContractBehavior =op.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
       if (dataContractBehavior != null)
       {
             dataContractBehavior.MaxItemsInObjectGraph = 2147483647;
       }
     }
    ISecurityAdministrationService client = factory.CreateChannel();
    return client;
}

这篇关于在maxItemsInObjectGraph属性通过从Silverlight应用程序如何我设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆