2
votes

My solution is Silverlight which uses WCF RIA service SP1 and Entity Framework 4.

I have a problem with loading large size data.

I've got this error message.

System.ServiceModel.DomainServices.Client.DomainException : Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

I think that it's a problem regards with timeout, so I tried below code. It worked when I hadn't install WCF Ria service "SP1". But it's not working since I've installed "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);

What should I do?

1

1 Answers

1
votes

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.