i have developed a simple Windows Forms app where i host a NetNamedPipeBinding service, and the same app is the client that tries to invoke a function in the service, but i got this error:
This request operation sent to net.pipe://service1/ did not receive a reply within the configured timeout (00:01:00). The time allotted to this operation may have been a portion of a longer timeout. This may be because the service is still processing the operation or because the service was unable to send a reply message. Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure thatthe service is able to connect to the client.
This is my service:
namespace WcfServiceExample
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string SayHello();
}
public class Service1 : IService1
{
public string SayHello()
{
return "Hello from " + Dns.GetHostName() + " !!";
}
}
}
This is my app.config (In my Windows Forms app):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<!-- CLIENT & SERVER BINDINGS -->
<bindings>
<netNamedPipeBinding>
<binding name="NamedPipeBinding">
<security mode="None" />
</binding>
</netNamedPipeBinding>
</bindings>
<!-- SERVER -->
<services>
<service name="WcfServiceExample.Service1" behaviorConfiguration="svc1behavior">
<endpoint address="net.pipe://service1" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="NamedPipedEndPoint" contract="WcfServiceExample.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="svc1behavior">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- CLIENT -->
<client>
<endpoint address="net.pipe://service1" binding="netNamedPipeBinding"
bindingConfiguration="NamedPipeBinding" contract="WcfServiceExample.IService1"
name="NamedPipedClientEndPoint" />
</client>
</system.serviceModel>
</configuration>
And this is my Windows Forms app:
namespace ServiceHostAndClientNamedPipesNoProxy
{
public partial class Form1 : Form
{
ServiceHost vHost;
IService1 sc;
public Form1()
{
InitializeComponent();
StartHostService();
StartClient();
}
private void StartHostService()
{
try
{
// Create the service instance
vHost = new ServiceHost(typeof(Service1));
// Open the service
vHost.Open();
}
catch (Exception ex)
{
vHost.Abort();
}
}
private void StartClient()
{
NetNamedPipeBinding binding = new NetNamedPipeBinding("NamedPipeBinding");
ChannelFactory<IService1> cf = new ChannelFactory<IService1>("NamedPipedClientEndPoint");
sc = cf.CreateChannel();
//((IContextChannel)sc).OperationTimeout = new TimeSpan(0, 3, 0);
textBox1.Text = "Connected to " + cf.Endpoint.Address.ToString();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
vHost.Close();
}
private void btnInvokeMethod_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
textBox2.Text = textBox2.Text + System.Environment.NewLine + sc.SayHello();
this.Cursor = Cursors.Default;
}
}
}
Please help, i am stuck with this!!!.
Thans in advance.