Find the next TCP port in .Net says how to do this in raw .net, but not how to safely to this with WCF.
In my unit tests, I need to use the NetTcpBinding, I do not wish to hard code the port it is using.
Therefore how can I get the NetTcpBinding to automatically choose a free port when used in my ServiceHost?
How can I get it to tell me the port (or full endpoint address) it has chosen?
Or how can I using .NET find a few port that is valid for a server to bind to?
Given that my bounty did not lead to any new answers, I think we can assume there is no good answer.