Solved

WCF named pipe operation timeout

Posted on 2012-03-16
2
1,349 Views
Last Modified: 2012-03-19
Hi,
I am new to WCF and have created a small test app (server and client all contained in one win form). When testing the client bit seems to find the server but eventually times out, it seems that the server method is not returning in time.
Please see if you can see what I am doing wrong in the code below :

        [ServiceContract]
        public interface IReturnText
        {
            [OperationContract]
            string ReturnSomeText(string value);
        }

        public class ReturnText : IReturnText
        {
            public string ReturnSomeText(string value)
            {
                return "returned: " + value;
            }
        }


        private ServiceHost host;

        private void bStartService_Click(object sender, EventArgs e)
        {

            host = new ServiceHost(typeof(ReturnText),
                    new Uri[]{
                            new Uri("net.pipe://localhost")
                            });

            host.AddServiceEndpoint(typeof(IReturnText), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), "MyPipe");

            host.Open();
       
        }


        private void bStopService_Click(object sender, EventArgs e)
        {
            host.Close();
        }

        private void bUserService_Click(object sender, EventArgs e)
        {

            ChannelFactory<IReturnText> pipeFactory =
                new ChannelFactory<IReturnText>(
                    new NetNamedPipeBinding(NetNamedPipeSecurityMode.None),
                    new EndpointAddress("net.pipe://localhost/MyPipe"));

            IReturnText pipeProxy = pipeFactory.CreateChannel();
            ((IContextChannel)pipeProxy).OperationTimeout = new TimeSpan(0, 0, 5);
            string s = pipeProxy.ReturnSomeText("abc");

        }
0
Comment
Question by:Alw1n
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37730717
try to implement client in a separate application.

have a look here:-
http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication
0
 

Author Closing Comment

by:Alw1n
ID: 37736532
argh! thanks I did it in one app for easier testing, still not sure why it doesn't work when in the same app though?
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question