المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : WCF catching EndPointNotFoundException



C# Programming
11-29-2009, 03:01 PM
I am trying to connect a client to server using WCF.

The following code works when the server code is loaded (named pipe, same machine).

m_app is initialized as follows:

const string address = @"net.pipe://localhost/Pipe";
EndpointAddress ep = new EndpointAddress(address);
m_app = ChannelFactory.CreateChannel(new NetNamedPipeBinding(), ep);

I am trying to catch the exception EndPointNotFoundException. The catch block below initially used EndPointNotFoundException but didn't work so I tried CommunicationException.

I want to catch the situation where the server is not present.

What am I missing?

try
{
LoginResult result = m_app.DoLogin(username, password);
return result;
}

catch (CommunicationException e)
{
}