tags:

views:

40

answers:

2

Help. I get the exception below when I try to run my service. I tried running the CMD LINE fix netsh http add iplisten ipaddress=127.0.0.1:8439 to fix the problem. Problem is I get an IP address successfully added message but I still get the error below when I run my application. Any idea how I can deal with this please?

An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll

Additional information: A registration already exists for URI 'http://127.0.0.1:8439/'.

A: 

You've probably got multiple endpoints listening on the same address- could tell for sure if you posted your config (or config code). Do you have an address attribute specified for each endpoint with a unique URI (including mex if applicable)?

nitzmahone
I am not using multiple endpoints in this case. Just the one. Just the one.
Just out of curiosity- why are you managing the channel and listener explicitly instead of just creating a ServiceHost with your custom binding? I've been doing WCF for a long time, and I've never seen anyone do it that way.
nitzmahone
I don't want to have to create a specific contract in this case. I just need a service that handles generic messages and then allows the user the flexibility of selecting a response for each request manually.
Dunno- that code works fine for me. Some other ideas: shut off the Visual Studio hosting process- it can keep your listener open longer than you want. You could also do this in a more "normal" fashion with a catchall contract (see http://weblogs.asp.net/pglavich/archive/2008/01/19/wcf-handling-generic-messages.aspx for example).
nitzmahone
A: 

I am not using a config here. I am simply creating a channel and listening on an endpoint for requests. However the listener throws the error posted when run.

 CustomBinding custombinding = new CustomBinding();
        custombinding.Elements.Add(new HttpTransportBindingElement());
        BindingParameterCollection paramCollection = new BindingParameterCollection();
        IChannelListener<IReplyChannel> listener = custombinding.BuildChannelListener<IReplyChannel>(new Uri(textBoxURI.Text), paramCollection);
        listener.Open();

        IReplyChannel channel = listener.AcceptChannel();
        //Start listening 
        channel.Open();
        //process received messages
        RequestContext request = channel.ReceiveRequest();