Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Please update com.unity.collections reference of System.Runtime.CompilerServices.Unsafe

Discussion in 'Package Manager' started by SLGSimon, Aug 21, 2019.

  1. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    Currently com.unity.collections is referencing System.Runtime.CompilerServices.Unsafe 4.3

    System.Memory requires System.Runtime.CompilerServices.Unsafe (>= 4.5.0) so anything referencing that will cause an error that cannot be fixed.

    Please move this out to a "nuget.xxx" package with updated versions.
     
    andywatts and GeorgeAdamon like this.
  2. ethan_jl_unity

    ethan_jl_unity

    Unity Technologies

    Joined:
    Sep 27, 2018
    Posts:
    99
    Hi there,

    I have forwarded this issue to the team in charge of the `com.unity.collections`. Thanks for the report.
     
    GeorgeAdamon likes this.
  3. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    Thanks @ethan_jl_unity.

    Would it also be possible to get some info on how these situations will be handled in the future, with unity packaging dlls from nuget?
     
  4. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    Sorry to ping you again, but is there an update on this? It's blocking updates to our shared libraries.
     
  5. GeorgeAdamon

    GeorgeAdamon

    Joined:
    May 31, 2017
    Posts:
    23
    +1
    This would be greatly appreciated. We are having massive issues with the NumSharp library at the moment, which needs System.Runtime.CompilerServices.Unsafe (>= 4.5.2) and at the same time we need Unity.Collections which ships with 4.0.3.0
     
    Last edited: Oct 1, 2019
  6. GeorgeAdamon

    GeorgeAdamon

    Joined:
    May 31, 2017
    Posts:
    23
    To circumvent my problem, I had to:
    1. Copy the folders com.unity.collections, com.unity.jobs, com.unity.test-framework and com.unity.test-framework.performance from Library/PackageCache/
    2. Paste them inside my Assets folder
    3. Delete or Disable System.Runtime.CompilerServices.Unsafe.dll from the Assets/com.unity.collections/
    4. Uninstall Unity.Collections and Unity.Jobs from the Package Manager
    So far everything works, and both NumSharp and Collections use the 4.5.2 version of System.Runtime.CompilerServices.Unsafe
     
  7. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    187
    @SLGSimon, @GeorgeAdamon,

    I am really sorry you're still having issues. The issues have been forwarded to the relevant teams and I'll follow-up on this. In the meantime, you can get unblocked in a less drastic manner by embedding the faulty packages - similar to the steps taken by @GeorgeAdamon, but under the
    Packages/
    directory. This allows the package manager to still see these packages and install their dependencies, and you don't need to remove them from the project manifest.

    So updated steps would look like:
    1. Copy only the folder com.unity.collections from Library/PackageCache/
    2. Paste it under
      Packages
      (optionally rename it to
      com.unity.collections
      so it has the same name as in its
      package.json
      file)
    3. Delete or Disable System.Runtime.CompilerServices.Unsafe.dll from the Packages/com.unity.collections/
     
  8. GeorgeAdamon

    GeorgeAdamon

    Joined:
    May 31, 2017
    Posts:
    23
    Thanks for the tip @maximeb_unity and we are looking forward for this issue to be resolved!
     
  9. Jeff_Blumenthal

    Jeff_Blumenthal

    Joined:
    Apr 7, 2017
    Posts:
    8
    Could I please get more detailed information on the locations of these folders? I have looked in my editor and project folders and cannot find them. I'm on 2019.2.3f1. Thank you.
     
    Last edited: Oct 28, 2019
  10. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    187
    Both
    Library/PackageCache/
    and
    Packages
    referred to folders directly in your project directory. Say your Unity project is in
    C:\Users\me\Documents\Unity\MyProject
    , then
    C:\Users\me\Documents\Unity\MyProject\Library\PackageCache
    and
    C:\Users\me\Documents\Unity\MyProject\Packages
    are the directories I was referring to.
     
  11. Jeff_Blumenthal

    Jeff_Blumenthal

    Joined:
    Apr 7, 2017
    Posts:
    8
    Thank you for the quick reply.

    For my project I did not have com.unity.collections package.

    I did solve my compile problems by downloading the latest nuget packages and then moving the following the netstandard2.0 dlls to my Plugins directory:

    System.Buffers.4.5.0
    System.Memory.4.5.3
    System.Runtime.CompilerServices.Unsafe.4.6.0

    Hopes this helps others.
     
  12. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    758
  13. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    They already have some nuget packages replicated in their package manager, just not all they are using. Though I haven't heard if this is their official way of dealing with the issue...
     
  14. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    758
    Yes but that package is not the official Nuget package, it is recompiled by Unity and when you want to use an official Nuget package that depends on another official Nuget package, it won't work. Or if you need some specific version and not the one that Unity provides.
     
  15. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    That's exactly what the link you provided is doing, it converts a nuget package to an npm/unity package. Unity - for who knows what reasons - has decided on npm as their package technology and I don't see that changing, so we just have to work within that framework.

    To make it work they're going to have to officially maintain a number of packages (nuget.xxx in the package manager), though I haven't heard anything official about this.
     
  16. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    @maximeb_unity Six months later and this is still a problem, and there have been a number of package updates since with no fix.

    Also you stated you were going to follow up with the relevant teams, what was the result of that?
     
  17. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    @xoofx as you're the author of of UnityNuGet and work on burst this is probably relevant to you.

    As I've been updating to 2019.3 I've noticed burst is now packing a whole bunch of nuget dlls. It even includes mono.cecil that is in the nuget.mono-cecil package?

    I'm getting two warnings when I load up unity with burst 1.2.1 but it doesn't seem to be affecting anything. If I try to remove the dlls burst breaks so I'm not sure how they relate to the unity editor, or what to do here.

    Could not load assembly System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
    UnityEngine.Debug:LogWarning(Object)
    Unity.Burst.Editor.BurstReflection:CollectAssembly(Assembly, HashSet`1) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:260)
    Unity.Burst.Editor.BurstReflection:CollectAssembly(Assembly, HashSet`1) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:256)
    Unity.Burst.Editor.BurstReflection:GetAssemblyList(AssembliesType) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:239)
    Unity.Burst.Editor.BurstLoader:.cctor() (at Packages/com.unity.burst@1.2.1/Editor/BurstLoader.cs:69)
    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes(Type[])

    Could not load assembly System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
    UnityEngine.Debug:LogWarning(Object)
    Unity.Burst.Editor.BurstReflection:CollectAssembly(Assembly, HashSet`1) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:260)
    Unity.Burst.Editor.BurstReflection:CollectAssembly(Assembly, HashSet`1) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:256)
    Unity.Burst.Editor.BurstReflection:CollectAssembly(Assembly, HashSet`1) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:256)
    Unity.Burst.Editor.BurstReflection:GetAssemblyList(AssembliesType) (at Packages/com.unity.burst@1.2.1/Editor/BurstReflection.cs:239)
    Unity.Burst.Editor.BurstLoader:.cctor() (at Packages/com.unity.burst@1.2.1/Editor/BurstLoader.cs:69)
    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes(Type[])
     
  18. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    286
    These DLLs are in a special folder .Runtime that is not supposed to be processed by Unity editor at all, they are not part of the user Editor AppDomain, so they can't be found by BurstReflection.
    I suspect that the issue you are seeing is likely coming from another package you are using that is actually using these DLLs. We should probably remove these warning in Burst because I'm not sure they are relevant when things can't be loaded (because that's likely not a code that will be bursted in the end)
     
  19. Mortuus17

    Mortuus17

    Joined:
    Jan 6, 2020
    Posts:
    6
    Not only has this behaviour not been fixed with the update of DOTS; things have gotten way worse.
    Previously, the answer provided by maximeb_unity helped.
    Now, updating DOTS, numerous CS0246 errors pop up (Namespace of individual packages couldn't be found, even between each other). When trying to import DOTS to a brand new HDRP project, with the second or third package already, infinite import loops occur (all dependencies shown in package manager installed IN "CORRECT" ORDER) - am I missing something? Am I the only one who observes this? How do I fix it? And most importantly: When won't we have to deal with this anymore?
     
  20. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    53
    @Mortuus17 there was a versioning problem recently, I think you need to manually update burst? Something like that. I don't think preview packages are shown as updates normally so you will have to turn them on or manually check available versions
     
  21. Mortuus17

    Mortuus17

    Joined:
    Jan 6, 2020
    Posts:
    6
    Unfortunately not.
    As said, this happens with blank HDRP projects, too.
    Upgrading to 2020.1.X(beta) fixes most compilation errors, but now the Entities namespace uses types that have been removed from Unity. I don't know what to say.
     
  22. unity_o-ud8Xgk1mqn3w

    unity_o-ud8Xgk1mqn3w

    Joined:
    Feb 10, 2018
    Posts:
    1
    Please update it's really annoying, I can't get to fix this error !
     
  23. greenheartgames

    greenheartgames

    Joined:
    Jan 29, 2015
    Posts:
    15
    +1 for a proper fix please. couldn't get the suggested workaround to work while trying to use System.Text.Json nuget package.
     
  24. coldwarrior5

    coldwarrior5

    Joined:
    Nov 9, 2016
    Posts:
    12
    +1 I also experienced the issue as I am using Ros# and they need Newtonsoft.Json.dll and the System.Runtime.CompilerServices.Unsafe.dll for it to work properly, with the recent changes to the DOTS package (collections, entities, jobs, etc.) I am getting conflicts between the two, please resolve this issue.

    For the Newtonsoft.json.dll the solution was relatively easy since you did create a package for it com.unity.nuget.newtonsoft-json@2.0.0 but you forgot to add an entry to the manifest.json, located under Project folde\Packages, so I had to do it manually, which is fine and works normally once done, but you should do that automatically.

    For the System.Runtime.CompilerServices.Unsafe.dll the solution is much more hacky and reduces performance since the collections package is treated as in development, so it is not optimized, but it also isn't very elegant, you essentially have to do this every time the package gets updated. Please take care of this, it is almost a year since this has been reported.
     
  25. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    49
    I am having a similar conflict issue with System.Runtime.CompilerServices.Unsafe.dll where I am attempting to use the MessagePack library (with a copy of this dll pasted into Assets/Plugins) and that works, but when I then attempt to install DOTS Entities it borks.
     
  26. UbiAnthonyB

    UbiAnthonyB

    Joined:
    Jun 28, 2019
    Posts:
    1
    Still a problem unfortunately :(
     
unityunity