I’m running a WCF service, and calling ServiceHost’s Open() method will raise an AddressAlreadyInUseException if the adress is ..err .. already in use !
Is there a way to test whether the address is available without raising an exception?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The addresses being used by the ServiceHost are listed in ServiceHost.BaseAddresses. You could potentially check there, prior to making your call.
Alternatively, just try to open the service, and catch and handle the AddressAlreadyInUseException gracefully. If you receive that, you know it’s in use, and you can move on to your secondary logic.