I recently installed the new .NET Framework 4.5 (previously was 4.0 installed) on my Server and I´m getting a System.ServiceModel.AddressAlreadyInUseException
w
This is because of some limitations in using the same port for both the netTcp endpoint and mex endpoint documented here refer section "Sharing a port between a service endpoint and a mex endpoint using the NetTcpBinding". In 4.0 the defaults for listenBackLog
and MaxConnections
were 10. In 4.5 these defaults were revised as 12 * ProcessorCount. This exception happens when you try to share a port between netTcpBinding and mex endpoint provided you have different values for these two properties. In 4.0 this worked fine as you have set these to the default values (10) and thus these settings do not differ on both endpoints. But in 4.5 these are left as 10 for netTcp endpoint, but computed as 12* ProcessorCount. So the exception.
To solve this issue there are 2 ways:
listenBackLog
and MaxConnections
) from the config. In this way you will get a default of 12 * Processor count automatically which is > than 4.0 defaults.Please check out this blog for more details.
When you host a WCF service in a console application you need to copy the App.config file from the WCF project to the console app and then delete the App.config file from the WCF project,if you don't you can also get the above error.