I am using third party libraries in my projects, one is
Diagflow for Unity and the second is Ros for Unity
My issue comes with the fastJSON.dll and NewtonSoft.Json.dll they both are sharing classes namespaces and i get the error
“The class X exist in both LIBRARY1 and LIBRARY2”
if i remove one of the 2 libraries errors dissapear, BUT there are third libraries that depend to both libraries, so if i remove one i can run the project but i get the error
“THIRDASEMBLY can not be load because it cant locate (THE LIBRARY I HAVE JUST DELETED)”
I cant modify those libraries since they are thirdparty, I have tried adding an extern alias following this example without success
I haven’t really used any of the libraries you’ve mentioned. However I doubt that there are actual type name collisions between those libraries. As far as I can tell the NetwonSoft library has all its classes inside its own namespace (Newtonsoft). So you could only get name collisions when you put two using statements of different namespaces inside the same file, or if the other library abusively uses the Newtonsoft namespace for its own class(es).
This is of course just an example. I haven’t actually used the libraries. You haven’t mentioned the actual classes and namespaces involved here. Are you sure you did not just mindlessly put up using statements? One of the most common example that doesn’t involve any third party libraries is the Random class. Unity has it’s own Random class inside the namespace UnityEngine. However there’s also a Random class inside the System namespace. They can happily co-exist next to each other. However you can not use both using statements at the same time. So
using UnityEngine; and
using System; is not possible at the same time when you want to refer to the Random class. In that case you have to use the full qualified classname, including the namespace.
If the two libraries in fact define a class with the same name inside the same namespace, you could simply blame the creators of those libraries. You said you tried the library alias solution. Did you actually create the [compiler configuration file “smcs.rsp”] and specify alias names for your two libraries?
As I mentioned since your question is lacking the actual details of your error / issue I will not go further into this. You can not expect us to download and import the libraries outselfs just to see what’s the actual issue.
ps: I often get the impression that some people think a using statement is somehow required to use a certain library. This is completely false. Using statements at the top of a file just make a namespace available for this file for convenience so you don’t have to type out the namespace all the time. A namespace also does not necessarily be related to one particular library, though it commonly is which might be the reason for that assumption. Namespaces are just a way of organising and seperating classes within the app domain specifically to avoid name collisions between third party libraries.
: UnityExternAlias/Assets/smcs.rsp at master · DashW/UnityExternAlias · GitHub
hello, sorry i should have added more resources to clarify my question, first i am adding an image showing the exact error i get
If its not legible (i chose that font size so i could add full script to the image) the exact error is:
The Class that is giving issues is for example: “Newton.Json.JsonIgnoreAtribute” and others “Newton.Json.X” classes
Thanks for pointing out the multiple using issue, but i indeed made sure that i wasnt adding multiple using statement, but to make sure here is a link to the apiaisdk github library that is using the namespace Newtonsoft.Json (from fastJSON) and here is a link to the rosharp library using that same namespace but from the Netwonsoft.Json dll.
into the extern alias issue i have added the alias to make sure i was using the correct Newtonsoft.Json class here is the resulted code, without showing any errors,
extern alias test2;
public class SetCameraInfoResponse : Message
public const string RosMessageName = "sensor_msgs/SetCameraInfo";
public bool success;
// True if the call succeeded
public string status_message;
// Used to give details about success
this.success = false;
this.status_message = "";
public SetCameraInfoResponse(bool success, string status_message)
this.success = success;
this.status_message = status_message;
but when unityeditor compiles the code it returns the next error:
so i searched and found about the smcs.rsp, i tried several times, without success, and when googling the error i found this
so i imagined that was simply not supported in newer versions (i am using 2019) and my next approach was to come to unity forum in case someone could give me an advice
Sorry for the lack of details i was in a hurry i should not have upload the question like this.
@Bunny83 thanks for your time any advice, even if its to simply stop trying to find a solution and write my own library is appreciated.