I'm trying to make instance of class EndpointAddress where parameter contains German umlaut.
For example:
EndpointAddress endpointAddress = new EndpointAddress("net.tcp://süd:8001/EmployeeService");
It always throws exception that given uri cannot be parsed. I have tried to replace the umlaut with an encoded value, but I get same exception:
Invalid URI: The hostname could not be parsed.
Did anyone had same problem before? Thank you in advance.
The parser probably doesn't know how to work with internationalized domain names (IDN). If you want to have such hostnames, you're going to have to do the Punycode encoding yourself. I haven't used it, but there's a core function IdnMapping.GetAscii that looks suitable — something like
EndpointAddress endpointAddress = new EndpointAddress(
"net.tcp://" + IdnMapping.GetAscii("süd") + ":8001/EmployeeService"
);
will perhaps work (forgive me if it doesn't, C# isn't my language).
Just as an extra note. WCF added support for IDN (both for hosting service + WCF client talking to a service with IDN name) in .Net 4.5. This documentation has some information about this.
So this exception will disappear as soon as you compile your app against .net 4.5
As suggested you have to enable IRI and IDN parsing before using this kind of URI.
Add this to your app.config:
<configuration>
<uri>
<idn enabled="All" />
<iriParsing enabled="true" />
</uri>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With