Search Unity

External dll causes "Could not load file or assembly 'PresentationCore, Version=3.0.0.0"

Discussion in 'Scripting' started by capsicum, Dec 27, 2017.

  1. capsicum

    capsicum

    Joined:
    Oct 30, 2013
    Posts:
    1
    I've written an extremely simple dll to figure out how it works. But I'm getting that ugly error.
    The source of the dll is

    Code (CSharp):
    1. using System;
    2. using System.Threading.Tasks;
    3.  
    4. namespace TTiles
    5. {
    6.     public class Class1
    7.     {
    8.         private const int DefaultExtent = 4096;
    9.  
    10.         public static int GetNumber()
    11.         {
    12.             return 5;
    13.         }
    14.  
    15.         public static async Task<int> GetNumberAsync()
    16.         {
    17.             await Task.Delay(TimeSpan.FromSeconds(3.4));
    18.  
    19.             return 5;
    20.         }
    21.     }
    22. }
    And the Unity script is basically just

    Code (CSharp):
    1. using System;
    2. using Mapbox.Platform;
    3. using TTiles;
    4.  
    5. namespace Assets.Scripts.Cache
    6. {
    7.     internal class TRequest : IAsyncRequest
    8.     {
    9.         #region External Headers - We don't need them!
    10. /*
    11.         [DllImport("TTiles")]
    12.         private static extern Task<Byte[]> GetTileAsync();
    13.  
    14.         [DllImport("TTiles")]
    15.         private static extern int GetNumber();
    16. */
    17.         #endregion
    18.  
    19.  
    20.  
    21.         #region Constructor
    22.  
    23.         public TRequest(Action<Response> callback, int timeout)
    24.         {
    25.             IsCompleted = false;
    26.             _callback = callback;
    27.             _timeout = timeout;
    28.  
    29.             GetVectorNumberAsync();
    30.         }
    31.  
    32.         #endregion
    33.  
    34.  
    35.         #region Private Methods
    36.  
    37.         private async void GetVectorNumberAsync()
    38.         {
    39.             try
    40.             {
    41.                 var number = await Class1.GetNumberAsync();
    42.                 Console.WriteLine(number);
    43.  
    44.             }
    45.             catch (Exception ex)
    46.             {
    47.                 Console.WriteLine(ex.Message);
    48.                 throw;
    49.             }
    50.  
    51.             IsCompleted = true;
    52.         }
    53.  
    54.  
    55.         #endregion
    56.  
    57.     }
    58. }
    59.  
    The dll is compiled as x64 in Visual Studio (because Unity is 64bit).
    The dll has been copied into the Assets\Plugins\ folder (automatically after every build).
    Unity isn't complaining about any compilation problems...

    I have enabled Experimental (.NET 4.6 Equivalent) in Unity.
    The dll is built with .NET 4.6.

    But I get this error on run.

    Any ideas?
    That error makes no sense to me..