UiPath - issue - "Newtonsoft.Json.JsonSerializationException: Cannot create and populate list type System"
【问题描述】
用 UiPath (2019.3.0 Community Edition) 编写了一个非常简单的Tool,但是运行的时候出现了异常,下图是 Designer panel 的 workflow 和 异常截图
以下是详细的报错信息:
19.3.0+Branch.master.Sha.5fdb43627d7d3c011018bb545ddf9470210d44a9 Cannot create and populate list type System.Collections.Generic.IReadOnlyCollection`1[System.String]. Path 'ReferencedAssemblies.$values', line 1, position 373. System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Cannot create and populate list type System.Collections.Generic.IReadOnlyCollection`1[System.String]. Path 'ReferencedAssemblies.$values', line 1, position 373. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: Newtonsoft.Json.JsonSerializationException: Cannot create and populate list type System.Collections.Generic.IReadOnlyCollection`1[System.String]. Path 'ReferencedAssemblies.$values', line 1, position 373. at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList(JsonReader reader, JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadMetadataProperties(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue, Object& newValue, String& id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObje...).
问题关键点:
Newtonsoft.Json.JsonSerializationException: Cannot create and populate list type System
【解决方法】
原因:
Newtonsoft.Json 不兼容版本被加载到了 Global Assembly Cache(GAC)里边。
操作:
第一步,在C盘中搜索 Newtonsoft.Json.dll
第二步,右键打开该文件所在文件夹 - Open Location
第三步,往上两级,将整个 Newtonsoft.Json 文件夹 剪切到另外别的地方保存
第四步,重新安装 UiPath,再次运行就没有报错了
【参考】
https://documentation.red-gate.com/clone2/troubleshooting/common-issues/newtonsoft-json-jsonserializationexception-cannot-create-and-populate-list-type