Search Unity

Multiple assemblies with equivalent identity have been imported...

Discussion in 'Windows' started by Ideki, Jul 24, 2016.

  1. Ideki

    Ideki

    Joined:
    Jul 24, 2016
    Posts:
    10
    Hi,

    I am designing an application to run on the Microsoft HoloLens using Unity for the user interaction.
    The application connects to an asmx webservice to retrieve data.

    I have a C# test program to test the connection and data retrieval from the webservice.
    I then followed this tutorial to generate a dll based on the weservice wsdl (
    )

    If use the following script to generate the dll:

    I added system.Data because my webservice returns DataSet data from a Database.
    I dropped that dll in the Assets folder of the Unity project.
    I also had to drop System.Data.dll, System.dll, and System.Web.Services.dll in it (took them from C:\Program Files\Unity Hololens 5.4.0b16-HTP\Editor\Data\Mono\lib\mono\unity folder)
    When I use the Unity editor, my application connects to the webservice and retrieve the data without problems.

    Next step, I followed this tutorial to make a HoloLens application from Unity (http://hololenshelpwebsite.com/Blog/EntryId/1006/HoloLens-Hello-World)
    While it work for their own Hello World, when I tried to build my own project from unity I receive the following error:

    So I added a ProjectFileHook.cs file under Editor with the following content:
    Code (CSharp):
    1. using System;
    2. using System.IO;
    3. using System.Linq;
    4. using System.Text;
    5. using System.Xml.Linq;
    6. using UnityEditor;
    7. using SyntaxTree.VisualStudio.Unity.Bridge;
    8. using UnityEngine;
    9.  
    10. // http://forum.unity3d.com/threads/missing-c-references-to-system-data.11361/
    11. // https://visualstudiogallery.msdn.microsoft.com/8d26236e-4a64-4d64-8486-7df95156aba9
    12.  
    13. [InitializeOnLoad]
    14. public class ProjectFileHook
    15. {
    16.     // necessary for XLinq to save the xml project file in utf8
    17.     class Utf8StringWriter : StringWriter
    18.     {
    19.         public override Encoding Encoding
    20.         {
    21.             get { return Encoding.UTF8; }
    22.         }
    23.     }
    24.  
    25.     static void ProcessNodesWithIncludeAttribute(XDocument document, string localName, string includeValue, Action<XElement> action)
    26.     {
    27.         var nodes = document
    28.             .Descendants()
    29.             .Where(p => p.Name.LocalName == localName);
    30.  
    31.         foreach (var node in nodes)
    32.         {
    33.             var xa = node.Attribute("Include");
    34.             if (xa != null && !string.IsNullOrEmpty(xa.Value) && string.Equals(xa.Value, includeValue))
    35.             {
    36.                 action(node);
    37.             }
    38.         }      
    39.     }
    40.  
    41.     // Remove System.Data from project (not from file system so Unity can compile properly)
    42.     static void RemoveFileFromProject(XDocument document, string fileName)
    43.     {
    44.         ProcessNodesWithIncludeAttribute(document, "None", fileName, element => element.Remove());      
    45.     }
    46.  
    47.     // Adjust references, by using the default framework assembly instead of local file (remove the HintPath)
    48.     static void RemoveHintPathFromReference(XDocument document, string assemblyName)
    49.     {
    50.         ProcessNodesWithIncludeAttribute(document, "Reference", assemblyName, element => element.Nodes().Remove());      
    51.     }
    52.  
    53.     static ProjectFileHook()
    54.     {
    55.         ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
    56.         {
    57.             var document = XDocument.Parse(content);
    58.  
    59.             RemoveFileFromProject(document, @"Assets\System.Data.dll");
    60.             RemoveHintPathFromReference(document, "System.Data");
    61.  
    62.             RemoveFileFromProject(document, @"Assets\System.Web.Services.dll");
    63.             RemoveHintPathFromReference(document, "System.Web.Services");
    64.  
    65.             RemoveFileFromProject(document, @"Assets\System.dll");
    66.             RemoveHintPathFromReference(document, "System");
    67.             var str = new Utf8StringWriter();
    68.             document.Save(str);
    69.  
    70.             return str.ToString();
    71.         };
    72.     }
    73. }
    But it looks like this does nothing.

    I am at a lost about how to fix this at the moment, and I really need experts help to figure it out.
     
    Last edited: Jul 24, 2016
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    First of all you have to check that those dlls are compatible with HoloLens, as that uses a subset of .NET.
    If that System.dll is the same one as the one that is available in .NET for HoloLens, then you should set plugin importer settings to not include that dll when building for WSA.
     
  3. Ideki

    Ideki

    Joined:
    Jul 24, 2016
    Posts:
    10
    How do I change the plugin importer settings ?
    I am really new to Unity, so it's a bit of a struggle to figure out the best way around.
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
  5. Ideki

    Ideki

    Joined:
    Jul 24, 2016
    Posts:
    10
    Ok, so I checked the plugin settings, and I am not sure what to set exactly

    First of all, I have imported System.dll from the Mono 2.0 folder into the plugins folder because the build said it could not find the references to System.Component
    Then when I built the project for the Windows Store I got the following error:

    It looks like it is a version conflicts.
    So then I changed the System.dll Plugin settings to "Don't process"
    But that did not seem to change anything in the outcome.

    I also changed the platform for plugin to be only for the Editor.
    But then I got the following error during the build:

    I attached a screenshot for the Plugin settings because for the Windows Store is does not look exactly like the one in the link you gave me.
    Screenshot.png
     
  6. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    Because System.dll is selected by AnyPlatform, it's also used by WSAPlayer, but that's wrong, because when building to Windows Store Apps, System.dll is picked from .NET Core framework. The same goes for other System.*.dll assemblies. Note: because Windows Store Apps uses .NET Core you cannot mix it with Mono assemblies.

    So at the very least, you have to unselect AnyPlatform, and select platforms except WSAPlayer.
     
  7. Ideki

    Ideki

    Joined:
    Jul 24, 2016
    Posts:
    10
    I just marked all the System.dll and System.*.dll as Editor and Standalone only.
    Now I get the following error (similar to what I had before:

    Is tried move the MyOwnWS.cs to the Asset folder directly, but the result was the same...

    Is there something to change somewhere to tell the build action to use the .Net dlls if it does not find them in the project ?
     
  8. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
  9. Ideki

    Ideki

    Joined:
    Jul 24, 2016
    Posts:
    10
    Yeah, I completely dropped this approach to webservice communication.
    Instead I am trying to use UnityWebRequest.

    But I am some problems that I posted here.
     
  10. Mafutta

    Mafutta

    Joined:
    Sep 30, 2014
    Posts:
    45
    has anyone encountered this error in unity 5.6.0f1
    APIUpdater encountered some issues and was not able to finish.


    System.IO.FileNotFoundException: Could not find file "/opt/Unity/Editor/Data/Mono/lib/mono/2.0/System.xml.dll".
    File name: '/opt/Unity/Editor/Data/Mono/lib/mono/2.0/System.xml.dll'
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0021a] in <5d83a8d54e334cdc853a0dba68082096>:0
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <5d83a8d54e334cdc853a0dba68082096>:0
    at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    at System.IO.File.OpenRead (System.String path) [0x00000] in <5d83a8d54e334cdc853a0dba68082096>:0
    at Roslyn.Utilities.FileUtilities.OpenFileStream (System.String path) [0x00000] in <bededc41dc2d4bfca1b18012876b04b2>:0
     
  11. visgraflab

    visgraflab

    Joined:
    Apr 4, 2017
    Posts:
    1
    Hi Mafutta.

    The problem is the name of the file.
    The file should be System.xml.dll, but on filesystem the filename is System.Xml.dll.
    You can rename the file to fix it or create a link.

    Solution 1:
    sudo mv /opt/Unity/Editor/Data/Mono/lib/mono/2.0/System.Xml.dll /opt/Unity/Editor/Data/Mono/lib/mono/2.0/System.xml.dll

    Solution 2:
    sudo ln -s /opt/Unity/Editor/Data/Mono/lib/mono/2.0/System.Xml.dll /opt/Unity/Editor/Data/Mono/lib/mono/2.0/System.xml.dll
     
    el_chino likes this.