Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

String conversion error: Illegal byte sequence encounted

Discussion in 'Editor & General Support' started by Aeonvirtual, Sep 2, 2020.

  1. Aeonvirtual

    Aeonvirtual

    Joined:
    Oct 14, 2015
    Posts:
    33
    On one of my devs pcs we get the following error when trying to play in the editor:


    ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
    System.Net.Dns.GetHostByName (System.String hostName) (at <14e3453b740b4bd690e8d4e5a013a715>:0)
    System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) (at <14e3453b740b4bd690e8d4e5a013a715>:0)
    av.Utils.GetLocalIPAddress () (at Assets/Scripts/AV/Utils.cs:145)
    av.AV.UpdateDeviceInfo () (at Assets/Scripts/AV/AV.cs:1028)
    av.SystemDialog.Show (System.Boolean debug) (at Assets/Scripts/AV/_dialog.cs:385)
    av.AV.Start () (at Assets/Scripts/AV/AV.cs:1122)

    We are trying to run this on 2019.4.7f1 and it runs fine on other machines. Google doesn't have many answers on this. Anyone have a clue?
     
    dan_ginovker likes this.
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    What does your code look like?

    Maybe it's expecting only IPv4 addresses (which are only numerical) and it's encountering an IPV6 address on your friend's PC?
     
  3. Aeonvirtual

    Aeonvirtual

    Joined:
    Oct 14, 2015
    Posts:
    33
    Code (CSharp):
    1.  public static string GetLocalIPAddress() {
    2.             var host = Dns.GetHostEntry(Dns.GetHostName());
    3.             foreach (var ip in host.AddressList) {
    4.                 if (ip.AddressFamily == AddressFamily.InterNetwork) {
    5.                     return ip.ToString();
    6.                 }
    7.             }
    8.             return null;
    9.         }
    Dns is the static system.net.dns class
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Have you tried printing out the value of
    Dns.GetHostName()
    ? What does it print on a working machine? What does it print on your friend's machine where it's not working?
     
  5. Aeonvirtual

    Aeonvirtual

    Joined:
    Oct 14, 2015
    Posts:
    33
    it prints 'PC' on my machine and it prints 'HautVoltage' on my friends machine.
     
  6. raidsnow

    raidsnow

    Joined:
    Oct 21, 2020
    Posts:
    1
    Hello.
    The same thing happened to me. On same version Unity.
    I think it was because I used double-byte characters in the computer name.
    I have not verified whether it is due to the version of unity, but how about it?
     
    dan_ginovker likes this.
  7. vlad1p

    vlad1p

    Joined:
    Nov 12, 2021
    Posts:
    3
    I had such a problem when integrating firebase. There were non-Latin literals on the way to the project. Changed the path. If you have the same problem as me, then Google swears.VersionHandler.
     
  8. Coredumping

    Coredumping

    Joined:
    Dec 17, 2014
    Posts:
    51
    This was the first thing that popped up on google when searching for the error, so I'm posting the solution I found somewhere else.

    Instead of using Dns.GetHostAddresses(Dns.GetHostName()) to find the local IP address you can use NetworkInterface from System.Net.NetworkInformation.

    Code (CSharp):
    1. foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
    2.     {
    3.     if (networkInterface.OperationalStatus == OperationalStatus.Up &&
    4.         (networkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||
    5.          networkInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211))
    6.         {
    7.         foreach (var ip in networkInterface.GetIPProperties().UnicastAddresses)
    8.             {
    9.             if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
    10.                 {
    11.                 return ip.Address.ToString();
    12.                 }
    13.             }
    14.         }
    15.     }