Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Type A Exists in both 'B' and 'C' Conflict When Building .NET UWP Project 2018.3

Discussion in 'Windows' started by csrussell, Apr 5, 2019.

  1. csrussell

    csrussell

    Joined:
    Jul 23, 2012
    Posts:
    4
    I'm having issues with a Unity project that was just recently migrated from 5.6.

    Specifically, the following line of code
    Code (CSharp):
    1. System.Net.Dns.BeginGetHostAddresses(this.path, this.ConnectingCallback_GetEndpoint, this.connectionSessionId);
    gives this error:
    Error CS0433 The type 'Dns' exists in both 'System.Net.NameResolution, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' Assembly-CSharp

    I've noticed that this only seems to occur when I have "Unity C# Projects" selected under the Build Settings for Debugging. Any thoughts on why this might be the case? As a side note, I briefly migrated to 2017 before going to 2018 and I don't think I saw this error there.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    Which Unity version are you on? This is weird indeed. It's likely we introduced it in 2018.3.6f1 when we bumped the Universal Windows Platform version in generated VS project. You can probably work around it by editing project.json and changing it back to 5.0.0.
     
  3. csrussell

    csrussell

    Joined:
    Jul 23, 2012
    Posts:
    4
    That didn't seem to help. I changed every project.json in the build from 5.4.4 to 5.0.0 and I don't see any change.

    I'm currently on Unity 2018.3.11f1. I'll install an older release and see if I still get this issue.
     
  4. csrussell

    csrussell

    Joined:
    Jul 23, 2012
    Posts:
    4
    Ok, I reverted to 2018.3.5f1 and the error has disappeared. Very peculiar indeed.

    *EDIT* I went ahead and changed the project.json UWP version on the working copy from 5.0.0 to 5.4.4 and it broke just like before. So yes, I think that must have been the reason (not sure why I couldn't get it working that way before though).
     
    Last edited: Apr 8, 2019
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    Can we get a bug report on this?
     
  6. csrussell

    csrussell

    Joined:
    Jul 23, 2012
    Posts:
    4
    I'm submitting one now. And FYI, on 2018.3.11f1 reverting to UWP 5.0.0 did work, I just had to restart Visual Studio, cleaning and rebuilding the solution was insufficient.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    Thank you!
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    The fix for this landed in Unity 2018.4.1f1 (which is going to be out soon).
     
  9. ChrisHorrigan

    ChrisHorrigan

    Joined:
    Jan 28, 2014
    Posts:
    6
    I upgraded my project to 2018.4.5f1 and I'm having this exact problem. Dns and IPHostEntry.
    error CS0433: The type 'IPHostEntry' exists in both 'System.Net.NameResolution, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

    error CS0433: The type 'Dns' exists in both 'System.Net.NameResolution, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    Are you getting these errors in Visual Studio or Unity editor? What's your minimum SDK target version is set to?
     
  11. ChrisHorrigan

    ChrisHorrigan

    Joined:
    Jan 28, 2014
    Posts:
    6
    If I open the script via Unity editor and write the code relating to that stuff, it actually works when I play in editor (no errors and functions correctly). But if I open the Visual Studio solution compiled for the UWP project it underlines it red and takes issue, or if I build to run in Visual Studio I get build errors that I pasted above.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    What's your minimum SDK target version is set to?
     
  13. ChrisHorrigan

    ChrisHorrigan

    Joined:
    Jan 28, 2014
    Posts:
    6
    Minimum platform version 10.0.10240.0, Target SDK version 10.0.18362.0
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    I just tried this and it works for me...

    Can you double check that you're actually on 2018.4.5f1? Secondly, can you check if this happens if you build to an empty folder?

    If you still run into this, could you paste exact code that triggers it or report a bug?
     
  15. ChrisHorrigan

    ChrisHorrigan

    Joined:
    Jan 28, 2014
    Posts:
    6
    I created a blank 2018.4.5f1 project and tried setting it up with the same build settings that I'm using for my other UWP project. This time it said "Dns does not contain a definition for 'GetHostEntry'" and GetHostName when building. It still works when just editing the script and then running in editor. Someone said on this Stack Overflow question that System.Net.Dns is not available in the .net framework for windows runtime (https://stackoverflow.com/questions/34754406/c-sharp-system-net-dns-universal-app-w10-not-working) so maybe the problem is that I'm doing .NET for the scripting backend rather than IL2CPP (which isn't an option for my case). I'll look at alternatives if this is indeed the issue.

    Here's the code anyway
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.Networking;
    6. using TMPro;
    7. using System.Net;
    8. using System.Net.NetworkInformation;
    9. using System.Net.Sockets;
    10.  
    11. public class NetworkHUD : MonoBehaviour
    12. {
    13.  
    14.     string localIP = "";
    15.     private NetworkManager manager;
    16.     void Awake()
    17.     {
    18.  
    19.         manager = GetComponent<NetworkManager>();
    20.         //Problem section:
    21.         IPHostEntry host;
    22.  
    23.         host = Dns.GetHostEntry(Dns.GetHostName());
    24.         foreach (IPAddress ip in host.AddressList)
    25.         {
    26.             if (ip.AddressFamily == AddressFamily.InterNetwork)
    27.             {
    28.                 localIP = ip.ToString();
    29.                 break;
    30.             }
    31.         }
    32.  
    33.         Debug.Log("LocalIP: " + localIP);
    34.     }
    35. }
    36.  
     
    Last edited: Aug 12, 2019 at 5:59 PM
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    Yeah, that's expected. .NET scripting backend only contains "BeginGetHostEntry" and "EndGetHostEntry" methods.