The accepted answer here did not work for me. Instead I had to cast the base channel into an IContextChannel, and set the OperationTimeout on that.
To do that, I had to create a new file with a partial class, that matched the name of the ServiceReference. In my case the I had a PrintReportsService. Code is below.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace RecipeManager.PrintReportsService
{
public partial class PrintReportsClient : System.ServiceModel.ClientBase<RecipeManager.PrintReportsService.PrintReports>, RecipeManager.PrintReportsService.PrintReports
{
public void SetOperationTimeout(TimeSpan timeout)
{
((System.ServiceModel.IContextChannel)base.Channel).OperationTimeout = timeout;
}
}
}
Then when I create the client, I do the following:
PrintReportsService.PrintReportsClient client = new RecipeManager.PrintReportsService.PrintReportsClient();
client.SetOperationTimeout(new TimeSpan(0, 4, 0));
That did it for me! More info is available here, but the code snippet in this post doesn't compile.