socket.io-unity icon indicating copy to clipboard operation
socket.io-unity copied to clipboard

Is defined multiple times

Open farzadi opened this issue 8 years ago • 58 comments
trafficstars

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<Tresult>' 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'

farzadi avatar Jul 12 '17 11:07 farzadi

Same problem. Hope soon will be fixed.

vnedilko avatar Jul 12 '17 14:07 vnedilko

It will be helpful if you can provide the version number of:

  • Unity
  • Mono
  • .NET

floatinghotpot avatar Jul 12 '17 14:07 floatinghotpot

Last version of unity 2017.1f3, released 11 July 2017

vnedilko avatar Jul 12 '17 16:07 vnedilko

Unity 5.5.1f1 .NET v4.5.x v4.5.x v4.6.x

farzadi avatar Jul 13 '17 06:07 farzadi

As I know, you can use .NET v4.5 on Windows/XBOX platform, but to build runtime for cross platform like iOS or Android, you need select Mono and .NET 2.0.

See: http://answers.unity3d.com/questions/1305565/as-of-12017-what-is-the-highest-version-of-net-tha.html

floatinghotpot avatar Jul 13 '17 07:07 floatinghotpot

This error present in editor and break all work. With lasterst release of unity you cant use this pluging becouse of error. Looks like you have same named classes.

vnedilko avatar Jul 13 '17 11:07 vnedilko

Settings untitled-1

Errors

error CS0433: The imported type `System.Action' is defined multiple times

error CS0433: The imported type `System.Func<TResult>' is defined multiple times

error CS0433: The imported type `System.Func<T,TResult>' is defined multiple times

vnedilko avatar Jul 13 '17 11:07 vnedilko

Weird, I still did not figure out what happens in your situation.

It works quite well when I test the demo project with Unity 5.4.4 in my office and Unity 5.6.1 at home.

Or, you may try building the library from source code here (using branch net20): https://github.com/floatinghotpot/SocketIoClientDotNet/tree/net20

floatinghotpot avatar Jul 13 '17 14:07 floatinghotpot

Hi guys, I just downloaded and install Unity 2017.1 (on my iMac), start the test-server/index.js, then open the Demo/Hello.unity in Unity, configure the URL, then run the demo in Unity, it works just fine. See the attached screenshot.

socketio-demo

floatinghotpot avatar Jul 13 '17 14:07 floatinghotpot

Also having this issue, with completely unrelated libraries.

Assets/ThirdParty/SteamVR/InteractionSystem/Core/Scripts/Util.cs(411,69): error CS0433: The imported type `System.Action' is defined multiple times

Sounds like maybe something in one of these DLLs is writing something to System.Action, which is causing unexpected other third party libraries using the same name?

jake avatar Jul 13 '17 16:07 jake

Yes if you just use this package its not have a problem, errors came from when you add other packages to your project

farzadi avatar Jul 14 '17 09:07 farzadi

Sample code for receive this issues

using System;
using UnityEngine;

public class Test:MonoBehaviour
{
    public Action callback;
    public Func<int> callback2;
    public Func<int, bool> callback3;
}

vnedilko avatar Jul 14 '17 09:07 vnedilko

I am seeing the same System.Action collision issue with a BLE plugin.

gershhub avatar Jul 19 '17 19:07 gershhub

Same problem here, System.Func<TResult>' is defined multiple times all around

Oakshiro avatar Jul 25 '17 11:07 Oakshiro

Encountering this problem with Vuforia. What can we do in such a case?

tbhyn avatar Aug 26 '17 06:08 tbhyn

Here is the source code, https://github.com/floatinghotpot/SocketIoClientDotNet/tree/net20

If anyone wanna contribute, try forking the code and help to fix it.

floatinghotpot avatar Sep 04 '17 23:09 floatinghotpot

Looks like two different packages try to define the same type in the same namespace by either

  • having two different dependencies that define the same Namespace.Type
  • maybe referring to two different versions of the same dependency

My eyes are on System.Threading.Tasks.Unofficial. It seems to be defining some types for compatibility. If, for example, some other plugin would be using the TaskParallelLibrary - then I could see why these two plugins would probably not work together.

Unfortunately I won't have any time for this until next week. If it's not solved by then I will have a look.

A sample project on Git to reproduce the issue would help a lot.

marius-bughiu avatar Sep 06 '17 18:09 marius-bughiu

I'm getting an error in Unity that is probably related to this.

ArgumentException: An element with the same key already exists in the dictionary.

It looks like that's being triggered when I try to connect to the server after initially declaring socket = null;. The error doesn't happen if I just do socket = "http://localhost:3000"; for example.

I'm also running on latest Unity 2017.1.1f1

alex-carlson avatar Sep 25 '17 00:09 alex-carlson

Just getting on the "I'm having problems too" train. Here's my output:

The type 'Func<T1, T2, TResult>' exists in both 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'WebSocket4Net, Version=0.14.1.0, Culture=neutral, PublicKeyToken=eb4e154b696bf72a'

As stated above, only seems to break in the presence of other packages. In my specific case it's https://github.com/neuecc/UniRx

Dr-Jerm avatar Oct 03 '17 22:10 Dr-Jerm

Just researching this for now... but: @marius-bughiu - Did you ever get a chance to work on this a bit more?

patricknelson avatar Dec 25 '17 22:12 patricknelson

I am using UnityAction until the problem will be solved. Here is the example usage,

using UnityEngine;
using UnityEngine.Events;

public class Test : MonoBehaviour 
{
	private void Start () 
	{
		DemoLog( () => 
		{
			Debug.Log("Second message"); 
		});
	}

	private void DemoLog(UnityAction callback)
	{
		Debug.Log("First message");
		callback();
	}
}

@floatinghotpot, can you fix this = https://github.com/floatinghotpot/socket.io-unity/issues/10 ? Thanks.

GkhanKINAY avatar Jan 09 '18 01:01 GkhanKINAY

Same problem here guys @GkhanKINAY Thank you for your tip, this saved my day :)

vellames2 avatar Jan 18 '18 23:01 vellames2

Hi , how is using UnityEngine.Events; supposed to fix the issue ? Currently at GGJ , conflicting with STEAMVR will be waitin for you answer. Thanks in advance!

siordache94 avatar Jan 27 '18 15:01 siordache94

@siordache94 Hi, good luck in GGJ. Use "UnityAction" instead of "Action" Where is your problem?

GkhanKINAY avatar Jan 27 '18 16:01 GkhanKINAY

it's very deep , if you try to import this and https://www.assetstore.unity3d.com/en/#!/content/32647 this asset, there's conflict on action , i tried putting either unityaction in steamvr , tried wrappin system in sys (in case of conflicting namespace) after changing all the references to system.action i get 40+ other errors. IF (and thats a big if) there's a quick fix that you know about ( i have little to no experience ) , please do share... thank you

siordache94 avatar Jan 27 '18 17:01 siordache94

@siordache94 I change Util.cs and now working, i think. Replace Assets/SteamVR/InteractionSystem/Core/Scripts/Util.cs

Util.cs.zip

GkhanKINAY avatar Jan 27 '18 17:01 GkhanKINAY

I'm having the same issue. Unity 2017.3 and .NET 3.5. Replacing System.Action with UnityAction works sometimes, but not always, so it isn't really a valid fix for me. Does anybody have any thoughts as to what might be causing this? I'm new to Unity and C#, so unfortunately I'm pretty clueless

James-Quigley avatar Jan 28 '18 20:01 James-Quigley

@GkhanKINAY If you think you've got a viable fix, could you submit a PR and reference this ticket?

patricknelson avatar Feb 01 '18 19:02 patricknelson

@patricknelson OK, i fixed the problem on the source code. (https://github.com/floatinghotpot/SocketIoClientDotNet/pull/1)

GkhanKINAY avatar Feb 01 '18 22:02 GkhanKINAY

Thanks to @GkhanKINAY , the file has been merged.

floatinghotpot avatar Feb 02 '18 00:02 floatinghotpot