c# - JSON Deserialize fails when linker is set to Link All -
i getting argumentnullexception when trying deserialize json on device. here exact error:
and here calling code:
private tmetadata readobject(string path) { var data = file.readalltext(path); var obj = jsonconvert.deserializeobject(data, _settings); return (tmetadata) obj; }
i read through this thread , realized linker problem. project set link when building device, , changing don't link not feasible due size constraints.
i inspected json text , found type trying deserialize, went class , marked preserve(allmembers = true)]. added same attribute user defined class being used in class. still same error, however. added --linkskip=assemblyname additional mtouch arguments , had no luck.
does have tips? there @ least way can more useful information xamarin? when exception happens takes me seemingly random line - event declaration in unrelated class - , clicking on methods in stack nothing. have no idea "method" parameter is.
here's stack starting after readobject call:
newtonsoft.json.utilities.validationutils.argumentnotnull(object value, string parametername) in newtonsoft.json.utilities.expressionreflectiondelegatefactory.createparametrizedconstructor(system.reflection.methodbase method) in newtonsoft.json.serialization.jsonarraycontract.createwrapper(system.collections.generic.dictionary<bluebeam.studio.client.sdk.sessions.sessionmarkupid,bluebeam.studio.client.sdk.sessions.serverstate.pending.pendingitems.pendingmarkupdto> list) in newtonsoft.json.serialization.jsonserializerinternalreader.createnewlist(newtonsoft.json.jsontextreader reader, newtonsoft.json.serialization.jsonarraycontract contract, bool createdfromnondefaultcreator) in newtonsoft.json.serialization.jsonserializerinternalreader.createlist(newtonsoft.json.jsontextreader reader, system.monotype objecttype, newtonsoft.json.serialization.jsonarraycontract contract, newtonsoft.json.serialization.jsonproperty member, object existingvalue, string id) in newtonsoft.json.serialization.jsonserializerinternalreader.createvalueinternal(newtonsoft.json.jsontextreader reader, system.monotype objecttype, newtonsoft.json.serialization.jsonarraycontract contract, newtonsoft.json.serialization.jsonproperty member, newtonsoft.json.serialization.jsonobjectcontract containercontract, newtonsoft.json.serialization.jsonproperty containermember, object existingvalue) in newtonsoft.json.serialization.jsonserializerinternalreader.setpropertyvalue(newtonsoft.json.serialization.jsonproperty property, newtonsoft.json.jsonconverter propertyconverter, newtonsoft.json.serialization.jsonobjectcontract containercontract, newtonsoft.json.serialization.jsonproperty containerproperty, newtonsoft.json.jsontextreader reader, bluebeam.studio.client.sdk.sessions.serverstate.pending.pendingitems.pendingmarkupsdata target) in newtonsoft.json.serialization.jsonserializerinternalreader.populateobject(bluebeam.studio.client.sdk.sessions.serverstate.pending.pendingitems.pendingmarkupsdata newobject, newtonsoft.json.jsontextreader reader, newtonsoft.json.serialization.jsonobjectcontract contract, newtonsoft.json.serialization.jsonproperty member, string id) in newtonsoft.json.serialization.jsonserializerinternalreader.createobject(newtonsoft.json.jsontextreader reader, system.type objecttype, newtonsoft.json.serialization.jsonobjectcontract contract, newtonsoft.json.serialization.jsonproperty member, newtonsoft.json.serialization.jsoncontainercontract containercontract, newtonsoft.json.serialization.jsonproperty containermember, object existingvalue) in newtonsoft.json.serialization.jsonserializerinternalreader.createvalueinternal(newtonsoft.json.jsontextreader reader, system.type objecttype, newtonsoft.json.serialization.jsoncontract contract, newtonsoft.json.serialization.jsonproperty member, newtonsoft.json.serialization.jsoncontainercontract containercontract, newtonsoft.json.serialization.jsonproperty containermember, object existingvalue) in newtonsoft.json.serialization.jsonserializerinternalreader.deserialize(newtonsoft.json.jsontextreader reader, system.type objecttype, bool checkadditionalcontent) in newtonsoft.json.jsonserializer.deserializeinternal(newtonsoft.json.jsontextreader reader, system.type objecttype) in newtonsoft.json.jsonserializer.deserialize(newtonsoft.json.jsontextreader reader, system.type objecttype) in newtonsoft.json.jsonconvert.deserializeobject(string value, system.type type, newtonsoft.json.jsonserializersettings settings) in newtonsoft.json.jsonconvert.deserializeobject(string value, newtonsoft.json.jsonserializersettings settings) in
the solution adding "--linkskip=newtonsoft.json" additional mtouch arguments. gusman suggestion!