HTTP 'System.InvalidOperationException' exception
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/'.
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)?
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();
精彩评论