Solved

WCF named pipe operation timeout

Posted on 2012-03-16
2
1,345 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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:…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

777 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