c# - json parsing with xamarin android -
i wrote code parse json string in android xamarin app.
var request = httpwebrequest.create(myurl); request.contenttype = "application/json"; request.method = "get"; using (httpwebresponse response = request.getresponse() httpwebresponse) { if (response.statuscode != httpstatuscode.ok) { console.out.writeline("error fetching data. server returned status code: {0}", response.statuscode); } using (streamreader reader = new streamreader(response.getresponsestream())) { string content = reader.readtoend(); if (string.isnullorwhitespace(content)) { console.out.writeline("response contained empty body..."); } else { list<billstablefields> billlist = newtonsoft.json.jsonconvert.deserializeobject<list<billstablefields>>(content); //return block } } }
but throws build error. appreciated new xamarin , can't find support anywhere else. build error got given below
c:\program files\msbuild\xamarin\android\xamarin.android.common.targets(5,5): error msb4018: "linkassemblies" task failed unexpectedly.
mono.cecil.resolutionexception: failed resolve system.diagnostics.tracelevel
at mono.linker.steps.markstep.marktype(typereference reference)
at mono.linker.steps.markstep.markfield(fieldreference reference)
at mono.linker.steps.markstep.initializefields(typedefinition type)
at mono.linker.steps.markstep.initializetype(typedefinition type)
at mono.linker.steps.markstep.initializeassembly(assemblydefinition assembly)
at mono.linker.steps.markstep.initialize()
at mono.linker.steps.markstep.process(linkcontext context)
at mono.linker.pipeline.process(linkcontext context)
at monodroid.tuner.linker.process(linkeroptions options, linkcontext& context)
at xamarin.android.tasks.linkassemblies.execute()
at microsoft.build.backend.taskexecutionhost.microsoft.build.backend.itaskexecutionhost.execute()
at microsoft.build.backend.taskbuilder.d__20.movenext() (msb4018) (loginapptest)
if linker fails "failed find type blah blah", means using desktop .net library somewhere in app. if json.net, remove desktop assembly , use version of json.net on component store (this xamarin's version of nuget, except things paid).
i make sure have latest version of xamarin.android.