I ran into this exception the other day where I was specifying a net.pipe://blablabla address and it would not parse into a System.Uri. I really thought I spotted a Microsoft bug and couldn’t figure out how to get around it since the framework code I had written required a System.Uri.
The problem was actually obvious. I just wish the exception message “Invalid URI: The hostname could not be parsed.” could have been a little more descriptive. Bottom line: I had a port number specified. I was working with Windows Communication Foundation (WCF) and had copied and pasted a net.tcp address and changed it to net.pipe so that I could, in a fashion that only a nerd could respect, test performance between net.tcp and Named Pipes on the same damn machine.
Most of us know that named pipes is the fastest communication method for cross-AppDomain communication on YOUR LOCAL MACHINE ONLY. In this respect, a port number does not make sense.
I hope this helps someone else out there that is ready to call it quits and become a yoga instructor.