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

Type Task<> exists in both Unity.Tasks and mscorelib

Discussion in 'Scripting' started by Deleted User, Mar 28, 2020.

  1. Deleted User

    Deleted User

    Guest

    Hello fellow coders. I have run across an infuriating issue. I am using System.Threading.Tasks in my project. I recently imported a new plugin (Google Firebase) which ships with it's own dll (Unity.Tasks). Well, it seems like the geniuses at Google didn't realize that Unity has full support of System.Threading.Tasks and decided to bundle that namespace with their dll. I cannot get rid of Unity.Tasks or it breaks Firebase. I cannot use an extern alias to reference mscorelib or I get errors stating that my code doesn't return a Task<> (when it indeed did before I used the alias). I am at a loss of what I should do here. I would really like to use firebase as it is very easy to implement, but I also need to use Tasks in my project for asynchronous programming. Anybody have any bright ideas?

    Note: I am using Unity 2020 beta 2 and .Net 4.0 with the IL2CPP backend. I have tried with .NET 2.0, mono backend, and Unity 2019.x. No success. Any and all help appreciated.

    upload_2020-3-27_21-43-28.png
     
    iuries and asmanjitha like this.
  2. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
  3. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
    use Firebase tasks as Firebase.Task
    use System tasks as System.Threading.Task
    if you want to favor one task over the other, use i.e.
    using Task = System.Threading.Task;


    or you can easily distinguish both if you just
    using FBTask = Firebase.Task;

    using SysTask = System.Threading.Task;


    I hope I'm understanding you correctly.
     
    Deeewer and ALIENPANDA like this.
  4. Deleted User

    Deleted User

    Guest

    So unfortunately I have tried using aliases already. The problem is that they both use the same namespace in different assemblies. so systask referencing System.Threading.Tasks wouldn't work because System.Threading.Tasks exists in 2 different dll's (mscorelib AND Unity.Tasks).
     
    iuries and Misha_Kh like this.
  5. Deleted User

    Deleted User

    Guest

    One workaround that almost worked was defining an alias in the reference tab in Visual Studio. I then called extern alias above my using statements. However for some reason that changed the type that my Task was so I couldn't use my async method
     
  6. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Can you upload a minimal example that's already set up to produce the error and ready to fiddle with?
     
  7. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
  8. Deleted User

    Deleted User

    Guest

    I have tried that post, the fix does not work in my case
     
  9. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    What about:
     
  10. bellicapax

    bellicapax

    Joined:
    Oct 5, 2016
    Posts:
    14
    The fix that worked from me came from this GitHub issue

    1. Remove the Unity.Compat and Unity.Tasks dlls from the Parse/ root folder
    2. Enable the Unity.Compat and Unity.Tasks dlls in the Parse/dotnet45/ folder
     
  11. Deleted User

    Deleted User

    Guest

    I was able to fix it. Sorry I have not answered. I uninstalled Firebase from my project and re-installed it using the Package Manager (with .NET set to 4.x). I can now use System.Threading.Tasks just fine with Firebase working as well. One thing to note is (for now) Firebase does not work on Android builds in the Unity 2020 beta. Just food for thought.
     
    mischinab likes this.
  12. legendrotemp

    legendrotemp

    Joined:
    Apr 4, 2020
    Posts:
    2
    bellicapax and ritesh_khokhani like this.
  13. Adrien-Gannerie

    Adrien-Gannerie

    Joined:
    Feb 18, 2015
    Posts:
    12
    The @bellicapax solution worked for me too ! Thanks guys !
     
    bellicapax likes this.
  14. advo

    advo

    Joined:
    Apr 6, 2016
    Posts:
    14
    bellicapax likes this.
  15. Tonio1308

    Tonio1308

    Joined:
    Sep 22, 2013
    Posts:
    6
    bellicapax likes this.
  16. uitel2

    uitel2

    Joined:
    Oct 23, 2017
    Posts:
    7
    Solved for me!
    I deleted Assets/Parse/Plugin Unity.Compact and Tasks, but not the dotnet45 folder
     
  17. Nerisma

    Nerisma

    Joined:
    May 11, 2015
    Posts:
    5
    This is still a working solution as of today.
     
    V-Rangers-Support likes this.
  18. tutanchacon

    tutanchacon

    Joined:
    Mar 18, 2014
    Posts:
    1
    Excellent!
    Thanks!
     
    eliteforcevn and bellicapax like this.
  19. shyxiaolong

    shyxiaolong

    Joined:
    Jan 14, 2021
    Posts:
    9
  20. impashmarburglar

    impashmarburglar

    Joined:
    Jan 25, 2020
    Posts:
    1
    It works still
     
  21. MailocUnity

    MailocUnity

    Joined:
    Jul 27, 2022
    Posts:
    1
    thanks, I was resolved it
     
  22. Arshia001

    Arshia001

    Joined:
    Sep 20, 2011
    Posts:
    7
    If you still have errors in Visual Studio after *disabling* the DLLs outside `dotNet45` via Unity's import settings, make sure to *delete* the files. Visual Studio seems to pick them up by mistake.
     
  23. ShadowlessStudios

    ShadowlessStudios

    Joined:
    Jan 8, 2017
    Posts:
    15
    Worked for me in 2022 almost 2023 :)
     
  24. Bug-Games

    Bug-Games

    Joined:
    Jan 1, 2018
    Posts:
    1
    Check this
    It will work
     
  25. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    183
    this thread is one terrible proof that Firebase is very bad craftmanship
    FIrebase is like -> "this is fine"
     
    Last edited: Dec 2, 2022
    jojue likes this.
  26. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    183
    DId you try if Firebase stuff works in IOS/Android mobile build still after deleting the 2 files?
     
    Last edited: Dec 2, 2022
  27. rebelactions

    rebelactions

    Joined:
    Jul 23, 2019
    Posts:
    2
  28. OneHelluvaGuy

    OneHelluvaGuy

    Joined:
    Feb 27, 2023
    Posts:
    5
    I know it's almost been 10 years but thanks so much man I was struggling with a similar error and I managed to solve it using a similar approach to the one you've stated. I got NuGet for Unity and I installed an API through it, directly in Unity. That's what fixed it for me, thanks a lot!
     
  29. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,529
    My goodness, a time traveller from 2030! :)
     
    Ryiah and orionsyndrome like this.
  30. rizwanunity23

    rizwanunity23

    Joined:
    Oct 4, 2023
    Posts:
    1
    Worked!
    parse folder is in assets
     
  31. ShadowlessStudios

    ShadowlessStudios

    Joined:
    Jan 8, 2017
    Posts:
    15
    Oh iam a little bit late but yes they work, maybe becosue i have 2 accounts ups :)
     
  32. yburonald

    yburonald

    Joined:
    Feb 11, 2021
    Posts:
    1
    still works, thanks!