floatinghotpot / socket.io-unity

socket.io client for Unity, power game client with node.js back-end
494 stars 76 forks source link

Is defined multiple times #1

Open farzadi opened 7 years ago

farzadi commented 7 years ago

I have errors in some of my packages. Is this error under test and resolving? if yes, please let me know how long it takes to be resolved and help me solve the problem temporarily. The packages that had conflict in my project were NGUI and UnityMainThreadDispatcher.

The type 'Action' exists in both 'SocketIoClientDotNet, Version =1.0.0.0 , Culture=neutral , PublicKeyToken=null' and System.Core, Version =3.5.0, Culture=neutral , PublicKeyToken = b77a5c561934e089'

and

The type'Func' exists in both 'System.Core', Version=3.5.0.0 , Culture=neutral,PublicKeyToken = b77a5c56193e089 and 'WebSocket4Net, Version =0.14.1.0 ,Culture=neutral ,PublicKeyToken = ed4e154b696bf72a'

JCanovas commented 6 years ago

same error with websocket4net.dll :
I am using it together with the oculus plugin "Oculus integration" and the error appears in System.Func...Any Solution? Thank you

Jezzamonn commented 5 years ago

Hm, running into this too, conflicting with mscorlib:

error CS0433: The type 'Action<T1, T2, T3>' exists in both 'WebSocket4Net, Version=0.14.1.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

gamedev2492 commented 5 years ago

No solutions for this???

Jezzamonn commented 5 years ago

For me, the issue I had was I was somewhere in my code or a framework I was using, I had my own enum or class that was also called Action, and in the same namespace. I think moving it into a different namespace helped me.

OptrixAU commented 5 years ago

This link is to .NET 2.0 versions of the libraries for WebSocket4Net that will both work in Unity and won't cause problems with non-2.0 features such as Func, Action and Linq.

https://drive.google.com/drive/folders/1p0MRrFCdbWM4oCNTv_wGvcRQ_PlZpnlP?usp=sharing

AlekOstolle commented 4 years ago

Is there a solution, can't still find one ? Should we do something to remove the Func in the package manager, instead of the dll ?

OptrixAU commented 4 years ago

The new versions of Unity (2018.4+) allow you to use .NET Standard 2 and .NET 4.x as your scripting backend. This means that you can use the much later versions of your libraries, so that this problem doesn't occur.

Alternatively, you need to do what I did for WebSocket4Net, and go into the code. If you search for the definition of 'func' and rename it to something else, you'll remove the problem.

It's caused by the fact that quite a few libraries use LINQ-style code techniques, and then define those types (like Action and Func) themselves so that they compile in .NET 2. If you remove those definitions, it should work.

AlekOstolle commented 4 years ago

@OptrixAU Sorry, so if I understand you, the WebSocket4Net you uploaded above (23 aug) is already corrected to remove the "func" ? Are the two others dlls in the drive required ?

Since I never edited a dll, i tryied yours and have others errors instead, like: "C:\Program Files\Unity\Hub\Editor\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\RectMask2D.cs(197,51): error CS1579: foreach statement cannot operate on variables of type 'HashSet' because 'HashSet' does not contain a public instance definition for 'GetEnumerator'"

May you help me, thx