WCF ria SP1 has timed out

My solution is Silverlight, which uses the WCF RIA SP1 and Entity Framework 4 services.

I have a problem loading big data.

I have this error message.

System.ServiceModel.DomainServices.Client.DomainException: Timed out. The wait period expires before the operation is completed or the server is not responding.

I think the problem is with the timeout, so I tried under the code. It worked when I did not install the WCF Ria "SP1" service. But it does not work since I 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?

+2
source share
1 answer

, , . .

, RIA - , :

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

. - 1 . , , -, Web.config . :

CustomEmployeeDomainContext, , , hook 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); 

    }
}

.

+1

Source: https://habr.com/ru/post/1731956/


All Articles