Silverlight 4 WCF RIA Service Timeout Problem

前端 未结 2 1426
孤城傲影
孤城傲影 2021-01-22 06:05

I have a Silverlight 4 usercontrol that calls a very long running WCF RIA service. As shown below, I am increasing the default timeout period.

_domainContext =          


        
相关标签:
2条回答
  • 2021-01-22 06:41

    There are two possibilities that come to mind:

    1. You have not configured your DomainService to serilalize enough objects. The default is very small. Try this tip I put in yesterday to increase the resultset allocation
    2. Your data source may be timing out. In that case you need to increase the command timeout for LINQ to SQL, EF, or ADO.NET accordingly. This is the less likely cause, but one to consider.
    0 讨论(0)
  • 2021-01-22 06:47

    I answered the same question here: WCF ria service SP1 timeout expired

    The answer:

    I'll explain my context and I wish it will work for my. I'm sure about that.

    First of all to call RIA services, and using some domain context, in my example:

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

    Nothing new until here. And with this I was facing every time that same timeout exception after 1 minute. I spend quite a lot of time trying to face how to change the timeout definition, I tried all possible changes in Web.config and nothing. The solution was:

    Create a CustomEmployeeDomainContext, that is a partial class localizated in the same path of the generated code and this class use the hook method OnCreate to change the behavior of created domain context. In this class you should wrote:

    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); 
    
        }
    }
    

    I looking forward for you feedback.

    0 讨论(0)
提交回复
热议问题