title: Converting a json string into a .NET Object in Xamarin
body: <p>I have read several other people who have had this question, and I have attempted those approaches. However, I am getting odd results I cannot pin down.</p>
  
  <p>I am using <a href="http://json2csharp.com/#" rel="noreferrer">http://json2csharp.com/#</a> to build the classes I use with the convert method.</p>
  
  <p>in my code I am using the following libraries</p>
  
  <pre><code>using System;
  using RestSharp;
  using Newtonsoft.Json;
  using Android.App;
  using Android.Content;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  using Android.OS;
  using System.Collections.Generic;
  using ZXing;
  using ZXing.Mobile;
  </code></pre>
  
  <p>I have a method built up to take the json string from my api call and convert it into c# objects using Json.NET</p>
  
  <pre><code>public void convert(String response)
  {
      Console.WriteLine("Response: " + response);
      Console.WriteLine("Check 1");
      var list = JsonConvert.DeserializeObject&lt;List&lt;RootObject&gt;&gt;(response);
      Console.WriteLine("Check 2");
      Console.WriteLine(list);
      Console.WriteLine("Check 3");
      for (int i = 0; i &lt; list.Count; i++) // Loop with for.
      {
          Console.WriteLine("Check 4");
          Console.WriteLine("Pass: " + i);
          Console.WriteLine(list[i]);
      }
      Console.WriteLine("Check 5");
  }
  
  public class Item
  {
      public string barcode { get; set; }
      public string name { get; set; }
      public string upvotes { get; set; }
      public string downvotes { get; set; }
      public string updated { get; set; }
  }
  
  public class RootObject
  {
      public List&lt;Item&gt; items { get; set; }
  }
  </code></pre>
  
  <p>Here is an example dataset from the API I am calling</p>
  
  <pre><code>{
    "items":[
     {
       "barcode": "12345",
       "name": "xxx",
       "upvotes": "0",
       "downvotes": "0",
       "updated": "1465103701673"
    },
    {
       "barcode": "1234",
       "name": "xxx",
       "upvotes": "0",
       "downvotes": "0",
       "updated": "1465103697375"
     },
     {
       "barcode": "123",
       "name": "xxx",
       "upvotes": "0",
       "downvotes": "0",
       "updated": "1465103688554"
     }
  ]}
  </code></pre>
  
  <p>No errors pop in the error log.</p>
  
  <p>If I try adding debugging as soon as I hit the line </p>
  
  <pre><code>var list = JsonConvert.DeserializeObject&lt;List&lt;RootObject&gt;&gt;(response);
  </code></pre>
  
  <p>I get the message "Frame not in Module"</p>
  
  <p>The code only goes as far as Check 1 and then seems to stop. Below is my Debug log from Visual Studio on what happens after I call convert.</p>
  
  <pre><code>    06-05 16:32:59.391 D/Mono    ( 3672): Assembly Ref addref PennyGeneral[0x813fcad0] -&gt; Newtonsoft.Json[0x82201ac8]: 2
      06-05 16:32:59.391 D/Mono    ( 3672): The request to load the retargetable assembly mscorlib v2.0.5.0 was remapped to mscorlib v2.0.5.0
      06-05 16:32:59.391 D/Mono    ( 3672): Assembly Ref addref Newtonsoft.Json[0x82201ac8] -&gt; mscorlib[0x76d8a880]: 12
      Response: {"items":[{"barcode": "12345","name": "xxx","upvotes": "0","downvotes": "0","updated": "1465103701673"},{"barcode": "1234","name": "xxx","upvotes": "0","downvotes": "0","updated": "1465103697375"},{"barcode": "123","name": "xxx","upvotes": "0","downvotes": "0","updated": "1465103688554"}]}
      06-05 16:32:59.392 I/mono-stdout( 3672): Response: {"items":[{"barcode": "12345","name": "xxx","upvotes": "0","downvotes": "0","updated": "1465103701673"},{"barcode": "1234","name": "xxx","upvotes": "0","downvotes": "0","updated": "1465103697375"},{"barcode": "123","name": "xxx","upvotes": "0","downvotes": "0","updated": "1465103688554"}]}
      Check 1
      06-05 16:32:59.393 I/mono-stdout( 3672): Check 1
      06-05 16:32:59.393 D/Mono    ( 3672): Remapped public key token of retargetable assembly System.Core from 7cec85d7bea7798e to b77a5c561934e089
      06-05 16:32:59.393 D/Mono    ( 3672): The request to load the retargetable assembly System.Core v2.0.5.0 was remapped to System.Core v2.0.5.0
      06-05 16:32:59.394 D/Mono    ( 3672): Unloading image System.Core.dll [0x85f686d0].
      06-05 16:32:59.394 D/Mono    ( 3672): Image addref System.Core[0x85f660f0] -&gt; System.Core.dll[0x82d98df8]: 4
      06-05 16:32:59.395 D/Mono    ( 3672): Config attempting to parse: 'System.Core.dll.config'.
      06-05 16:32:59.395 D/Mono    ( 3672): Config attempting to parse: '/Users/builder/data/lanes/3236/ee215fc9/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/System.Core/System.Core.config'.
      06-05 16:32:59.395 D/Mono    ( 3672): Assembly Ref addref Newtonsoft.Json[0x82201ac8] -&gt; System.Core[0x82df1b18]: 4
      06-05 16:32:59.427 D/Mono    ( 3672): Remapped public key token of retargetable assembly System from 7cec85d7bea7798e to b77a5c561934e089
      06-05 16:32:59.427 D/Mono    ( 3672): The request to load the retargetable assembly System v2.0.5.0 was remapped to System v2.0.5.0
      06-05 16:32:59.428 D/Mono    ( 3672): Unloading image System.dll [0x85fb77d0].
      06-05 16:32:59.428 D/Mono    ( 3672): Image addref System[0x85fb94b0] -&gt; System.dll[0x830252a0]: 4
      06-05 16:32:59.428 D/Mono    ( 3672): Config attempting to parse: 'System.dll.config'.
      06-05 16:32:59.428 D/Mono    ( 3672): Config attempting to parse: '/Users/builder/data/lanes/3236/ee215fc9/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/System/System.config'.
      06-05 16:32:59.428 D/Mono    ( 3672): Assembly Ref addref Newtonsoft.Json[0x82201ac8] -&gt; System[0x8302f6e0]: 4
      06-05 16:32:59.475 D/Mono    ( 3672): Remapped public key token of retargetable assembly System.Runtime.Serialization from 7cec85d7bea7798e to b77a5c561934e089
      06-05 16:32:59.475 D/Mono    ( 3672): The request to load the retargetable assembly System.Runtime.Serialization v2.0.5.0 was remapped to System.Runtime.Serialization v2.0.5.0
      06-05 16:32:59.476 D/Mono    ( 3672): Image addref System.Runtime.Serialization[0x86002d60] -&gt; System.Runtime.Serialization.dll[0x86002098]: 1
      06-05 16:32:59.476 D/Mono    ( 3672): Assembly System.Runtime.Serialization[0x86002d60] added to domain RootDomain, ref_count=1
      06-05 16:32:59.476 D/Mono    ( 3672): AOT module 'System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app-lib/PennyGeneral.PennyGeneral-2/libaot-System.Runtime.Serialization.dll.so" not found
      06-05 16:32:59.477 D/Mono    ( 3672): AOT module '/Users/builder/data/lanes/3236/ee215fc9/source/monodroid/builds/install/mono-armv7/lib/mono/aot-cache/arm/System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app-lib/PennyGeneral.PennyGeneral-2/libaot-System.Runtime.Serialization.dll.so" not found
      06-05 16:32:59.477 D/Mono    ( 3672): Unloading image data-0x8602f008 [0x86002f78].
      06-05 16:32:59.478 D/Mono    ( 3672): Config attempting to parse: 'System.Runtime.Serialization.dll.config'.
      06-05 16:32:59.478 D/Mono    ( 3672): Config attempting to parse: '/Users/builder/data/lanes/3236/ee215fc9/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/System.Runtime.Serialization/System.Runtime.Serialization.config'.
      06-05 16:32:59.478 D/Mono    ( 3672): Assembly Ref addref Newtonsoft.Json[0x82201ac8] -&gt; System.Runtime.Serialization[0x86002d60]: 2
      Loaded assembly: System.Runtime.Serialization.dll [External]
      06-05 16:32:59.478 D/Mono    ( 3672): Assembly Ref addref System.Runtime.Serialization[0x86002d60] -&gt; mscorlib[0x76d8a880]: 13
      06-05 16:32:59.500 D/Mono    ( 3672): Assembly Ref addref System.Core[0x82df1b18] -&gt; System[0x8302f6e0]: 5
      Loaded assembly: Anonymously Hosted DynamicMethods Assembly [External]
      Thread finished: &lt;Thread Pool&gt; #5
      06-05 16:33:09.774 D/Mono    ( 3672): [0x834fab30] worker finishing
      06-05 16:33:09.781 D/dalvikvm( 3672): threadid=16: bye!
      The thread 'Unknown' (0x5) has exited with code 0 (0x0).
      Thread finished: &lt;Thread Pool&gt; #7
      06-05 16:33:37.391 D/Mono    ( 3672): [0x85274538] worker finishing
      06-05 16:33:37.398 D/dalvikvm( 3672): threadid=20: bye!
      The thread 'Unknown' (0x7) has exited with code 0 (0x0).
      Thread finished: &lt;Thread Pool&gt; #8
      06-05 16:33:53.046 D/Mono    ( 3672): [0x851f1b60] worker finishing
      06-05 16:33:53.052 D/dalvikvm( 3672): threadid=19: bye!
      The thread 'Unknown' (0x8) has exited with code 0 (0x0).
      Thread finished: &lt;Thread Pool&gt; #3
      06-05 16:33:59.536 D/dalvikvm( 3672): threadid=15: bye!
      The thread 'Unknown' (0x3) has exited with code 0 (0x0).
      Thread started: &lt;Thread Pool&gt; #10
      Thread started: &lt;Thread Pool&gt; #11
      06-05 16:34:39.062 D/dalvikvm( 3672): threadid=15: interp stack at 0x83950000
      06-05 16:34:39.064 D/dalvikvm( 3672): threadid=16: interp stack at 0x83970000
      06-05 16:34:39.065 D/Mono    ( 3672): [0x834fa728] worker starting
      Thread finished: &lt;Thread Pool&gt; #11
      06-05 16:34:59.711 D/Mono    ( 3672): [0x834fa728] worker finishing
      06-05 16:34:59.717 D/dalvikvm( 3672): threadid=16: bye!
      The thread 'Unknown' (0xb) has exited with code 0 (0x0).
  </code></pre>