Solved

WCF named pipe operation timeout

Posted on 2012-03-16
2
1,354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 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