Search code examples
unity-game-engineupgradensubstitute

error CS0433: The type ThreadLocal<T> exists in both NSubstitute and mscorlib


I upgraded from Unity 2019.2.21 to 2019.4.5.

Now I'm getting this error:

Library/PackageCache/com.unity.scriptablebuildpipeline@1.7.3/
Editor/Utilities/BuildLog.cs(51,9): error CS0433: The type 
'ThreadLocal<T>' exists in both 'NSubstitute, Version=0.0.0.0, 
Culture=neutral, PublicKeyToken=92dd2e9066daa5ca' and 'mscorlib, 
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

It's strange because everything worked fine in Unity 2019.2.21.

This question looks similar, but wasn't able to help me.

Any ideas?


Solution

  • I upgraded my NSubstitute.dll to version 2.0.3 as described in this answer, which fixed the issue.

    Apparently older versions of NSubstitute defined ThreadLocal themselves, which was causing my issue (thanks David Tchepak!).