Search code examples
c#visual-studio-mac

ExtendedSocketException thrown at run time


I have a project developed in C# using Visual Studio for mac. Unfortunately it works fine sometimes & failed sometimes. The code and the exception as follows.
How can I resolve this?

public static class ServerSettings
{
    public static string Version = "xxx";
    public static string[] IpAddresses
    {
        get
        {
            var hostName = Dns.GetHostName();
            var ipHostEntry = Dns.GetHostEntry(hostName);
            return ipHostEntry.AddressList
                .Where(a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                .Select(a => a.ToString())
                .ToArray();
            
        }
    }
} 

enter image description here

Console Log:
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll

If you need more details please let me know.


Solution

  • In my case inside the machine name there were Japanese characters(something like MMKのMacBook) which caused the problem. This may be a stupid answer but, after removing those Japanese characters I could able to manage the successful connection with the server.
    Thank you for your suggestions.