【问题标题】:WCF ria service SP1 timeout expiredWCF ria 服务 SP1 超时已过期
【发布时间】:2011-07-25 05:00:13
【问题描述】:

我的解决方案是 Silverlight,它使用 WCF RIA 服务 SP1 和实体框架 4。

我在加载大尺寸数据时遇到问题。

我收到此错误消息。

System.ServiceModel.DomainServices.Client.DomainException:超时已过期。在操作完成之前超时时间已过或服务器没有响应。

我认为这是超时的问题,所以我尝试了下面的代码。它在我没有安装 WCF Ria 服务“SP1”时工作。 但是自从我安装了“SP1”后它就不起作用了。

ChannelFactory<BatchContext.IBatchServiceContract> channel = ((WebDomainClient<BatchContext.IBatchServiceContract>)this.DomainClient).ChannelFactory;
channel.Endpoint.Binding.OpenTimeout = new TimeSpan(0, 30, 0);  
channel.Endpoint.Binding.CloseTimeout = new TimeSpan(0, 30, 0);    
channel.Endpoint.Binding.ReceiveTimeout = new TimeSpan(0, 30, 0);    
channel.Endpoint.Binding.SendTimeout = new TimeSpan(0, 30, 0);

我该怎么办?

【问题讨论】:

    标签: entity-framework-4 timeout wcf-ria-services


    【解决方案1】:

    我会解释我的背景,我希望它对我有用。我很确定。

    首先调用 RIA 服务,并使用一些域上下文,在我的示例中:

    EmployeeDomainContext context = new EmployeeDomainContext();
    InvokeOperation<bool> invokeOperation = context.GenerateTMEAccessByEmployee(1, 'Bob');
    invokeOperation.Completed += (s, x) =>
        {....};
    

    在此之前没有什么新鲜事。有了这个,我每次在 1 分钟后都面临同样的超时异常。我花了很多时间试图面对如何更改超时定义,我尝试了 Web.config 中所有可能的更改,但什么也没做。解决方案是:

    创建一个CustomEmployeeDomainContext,这是一个局部类本地化在生成代码的同一路径,这个类使用钩子方法OnCreate来改变创建的域上下文的行为。在这堂课中,你应该写:

    public partial class EmployeeDomainContext : DomainContext
    {
        partial void OnCreated()
        {
            PropertyInfo channelFactoryProperty = this.DomainClient.GetType().GetProperty("ChannelFactory");
            if (channelFactoryProperty == null)
            {
                throw new InvalidOperationException(
                  "There is no 'ChannelFactory' property on the DomainClient.");
            }
    
            ChannelFactory factory = (ChannelFactory)channelFactoryProperty.GetValue(this.DomainClient, null);
    
            factory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 10, 0); 
    
        }
    }
    

    期待您的反馈。

    【讨论】:

      猜你喜欢
      • 2011-01-14
      • 2013-05-12
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 2011-03-26
      相关资源
      最近更新 更多