On 11 November 2015 at 17:43, Thomas Koster <tkos...@gmail.com> wrote: > I am parsing a URL to connect to a WCF service. Try this: > > new Uri("net.tcp://guest:guest@myserver:12345"); > > I get a UriFormatException that complains about an invalid port > number. Uri.TryCreate is no better. > > It works if I remove the userinfo (credentials). It also works if I > don't use a scheme with a dot in it. I need both, however. > > As far as I can tell, this *is* a valid URI according to RFC 2396 and > RFC 3986. It works in Mono. It works in other languages. I think > .NET's URI parser is busted (Framework 4.5).
Using UriBuilder to create this Uri is also broken. Try this: var ub = new UriBuilder(); ub.Scheme = "net.tcp"; ub.UserName = "guest"; ub.Password = "guest"; ub.Host = "myserver"; ub.Port = 12345; The Uri property getter for ub throws the same UriFormatException as above. This is all *very* annoying. Thomas Koster