Saturday, June 26, 2010

WCF: Address Already In Use Exception

If you get this exception:

AddressAlreadyInUseException: Cannot listen on pipe name 'net.pipe://myservice/' because another pipe endpoint is already listening on that name.

Chances are you have one of the following issues:
  1. You have duplicate endpoints with exactly the same address. Double check your app.config endpoint declarations and/or code endpoint declarations.
  2. Ensure all ServiceContracts attributes have been uniquely namespaced.     [ServiceContract(Namespace = "")]
  3. Not sure how relevant this is, but I had an instance when this exception was resolved by changing my net.pipe endpoint url to net.pipe://localhost/servicename.  It was something like net.pipe://myservice/servicename.  Seems like a reasonable best-practice to always use localhost anyhow.
  4. Ensure the system tray Visual Studio WCF Host is not present in the system tray. Sometimes this thing can get confused at not restart correctly.
Yes you can have multiple processes all using net.pipe binding as long as they are using unique endpoint urls and unique service contract namespaces.

Hope that helps someone else.

1 comment:

  1. This is also related to an AddressAccessDeniedException. See here