Click here to Skip to main content
16,008,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I recently upgraded my .net framework version.
The service now throws AddressAlreadyInUse Exception. Earlier it used to work fine.
I am using TCP binding in my wcf.
Please help.

Thanks in advance :)

Regards,
Praneet
Posted

Hi,

I solved it.

I removed listenBacklog and maxConnections property from nettcpbinding.
It is now working fine.

Regards,
Praneet
 
Share this answer
 
v2
Re problem 1:

The WCF NetTcpBinding uses a shared memory section to publish to its clients the actual name of the service over which the service can be called. The pipe name itself is a GUID, generated afresh each time the service host is opened. It is the name of the shared memory section used to publish the service which is dependant on the service URL. If a base address is defined, the base address is used to derive this name.

This means you can only ever have one WCF service application at a time running which uses a particular base address for its NetTcp endpoints. If you try to start a second one, it fails with AddressAlreadyInUseException because it finds that the name WCF wants to use for the publishing location (derived from the base address) has already been taken by another application.

If you specify no base address, and give each service an absolute, unique service URL, then the name of the publishing location is now derived from the full absolute URL, and there is no name clash between the applications. This is an entirely valid and safe way to have multiple WCF services listening.

Re problem 2:

On the service side you can use anything for the host name part of the service URL. This is due to the HostNameComparisonMode setting applied by default in the NetTcpBinding, since the algorithm in WCF which derives the name for the shared memory publishing location substitutes a wildcard character for the host name see here to enable the configured host name comparison mode to be implemented.

On the client side, however, the service URL is constrained: the host part must genuinely resolve to localhost (i.e. it is localhost, the correct IP address, or the correct machine name).
 
Share this answer
 
Comments
[no name] 13-May-14 23:54pm    
Hi,
Thanks for your reply.
But then, I have a doubt. Why does the same code run on framework 3.5 ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900