When I try to run my workflow I get these “validation errors”:
‘JObject’ is ambiguous in the namespace ‘Newtonsoft.Json.Linq’.
‘JArray’ is ambiguous in the namespace ‘Newtonsoft.Json.Linq’.
The workflow does not show any validation errors before I try to run it.
My guess is that because I have several different packages dependent on different versions of Newtonsoft.Json, Uipath thinks JObject and JArray are ambiguous, but what do I do about it?
I have found out that it only happens when I use the invoke code activity and pass an argument which is of type JObject or JArray.
I have found a workaround for my specific case.
My workaround is that I found a way to do what I wanted without using the invoke code activity.
It should still be fixed in case the invoke code activity is necessary for ones workflow.
When using invoke code, it does not help to import Newtonsoft.Json or using the entire path to create a new object.
ok, in one case the fully qualifying of types for variable definitions helped me for stepping out from such issues. However you got it working and this is important. happy automation
Was that project of yours imported by another studio version by some way? do you have any errors if you create brand new project? Also do you mind to send us a screenshot of your project dependencies?
Nope, the error occurs as soon as I try to pass an argument of type JObject or JArray to an invoke code activity. Even if I begin a brand new project.
I have three packages (UiPath.System.Activities, UiPath.UIAutomation.Activities and UiPath.WebAPI.Activities) which have Newtonsoft.Json v. 11.0.2 as dependency and one non-standard package which has Newtonsoft.Json v. 12.0.2 as a dependency.
The packages with dependency Newtonsoft.Json v. 11.0.2 should be using Newtonsoft.Json v. 12.0.2, so there should only be one version of Newtonsoft.Json.
what do you mean Should be using 12.0.2? every package has its own dependencies defined by the developer… if you end up installing packages that interfere with one another, this wont be a bug of an activity…
I have not installed several versions of Newtonsoft.Json.
When looking at my dependencies in studio, under the packages that need 11.0.2, the rectangle is a lighter blue, and when I mouse over it says: “Requested >= 11.0.2, resolved 12.0.2”.
I take this to mean that since I have 12.0.2, the three packages requesting 11.0.2 use 12.0.2 instead.
Also, I have no problem using JObject and JArray in all other activities. It is only a problem when using invoke code.
Did you have two packages which have different versions of Newtonsoft.Json as dependencies?
And did you try giving your invoke code an argument of type JObject?
Everything works fine if I delete the package which needs >=12.0.2.
But should it not be possible to use packages which need different versions of the same library?
Especially when the version they need is described as >= 11.0.2 and >=12.0.2 ?
well, that could happen but since packages are the way they are, we cant fight with them… if you really need the one that depends on 12.0.2, then try to remove manually the DLL for the 11.0.2 from your project to see if it works. Also remember that the activities in the packages are working, just invoke code dont have a way to force an specific version…