title: Error in Realm Query at (wrapper managed-to-native) Realms.NativeTable.get_string
body: <p>I'm attempting to do a simple query on my first Realm database. I'm getting an error while trying to access the attributes of an object returned by my query method.
  I have two questions:<br>
   1. What's the meaning of this error? I'm having trouble to understand it...<br>
   2. Am I doing the query the right way? If not, what am I doing wrong?  </p>
  
  <p>The error log:</p>
  
  <pre><code>[mono-rt] Stacktrace:
  
  [mono-rt]   at &lt;unknown&gt; &lt;0xffffffff&gt;
  
  [mono-rt]   at (wrapper managed-to-native) Realms.NativeTable.get_string &gt;(Realms.TableHandle,intptr,intptr,intptr,intptr,bool&amp;) &lt;0x00057&gt;
  
  [mono-rt]   at Realms.RealmObject.GetStringValue (string) &lt;IL 0x0009d, &gt;0x00323&gt;
  
  [mono-rt]   at EasyVending.RCreditCard.get_holderName () &lt;IL 0x0000e, 0x0006f&gt;
  
  [mono-rt]   at EasyVending.RealmManager.getCreditCard () [0x0001c] in /Users/Bernardo/Projects/EasyVending/EasyVending/DataBase/RealmManager.cs:75
  
  [mono-rt]   at EasyVending.Android.CreditCartManagement.OnCreate (Android.OS.Bundle) [0x00111] in /Users/Bernardo/Projects/EasyVending/EasyVending.Android/Activities/CreditCartManagement.cs:89
  
  [mono-rt]   at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) &lt;IL 0x00013, 0x000ff&gt;
  
  [mono-rt]   at (wrapper dynamic-method) object.13add723-97a5-4397-9c8a-e6fc23d98c3c (intptr,intptr,intptr) &lt;IL 0x00017, 0x00043&gt;
  
  [mono-rt]   at (wrapper native-to-managed) object.13add723-97a5-4397-9c8a-e6fc23d98c3c (intptr,intptr,intptr) &lt;IL 0x0001f, 0x00097&gt;
  
  [mono-rt] Attempting native Android stacktrace:
  
  [mono-rt]  at ???+1 [0xbe903ac0]
  
  [mono-rt]  at ???+1 [0x98f50ffc]
  
  =================================================================
  
  Got a SIGSEGV while executing native code. This usually indicates
  [mono-rt] a fatal error in the mono runtime or one of the native libraries 
  [mono-rt] used by your application.
  [mono-rt]
  
  [libc] Fatal signal 11 (SIGSEGV), code 1, fault addr 0x97b77168 in tid 9849 (vending_android)
  </code></pre>
  
  <p>=====================================</p>
  
  <pre><code>public class RCreditCard : RealmObject {
      public string holderName { get; set; }
      public string bandeira { get; set; }
      public string digitos { get; set; }
      public string token { get; set; }
  }
  
  public class RealmManager {
      private string databaseName {
          get {
              return "PayBluDatabase.db";
          }
      }
      private string androidPath {
          get {
              return Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), databaseName);
          }
      }
  
      public Realm getRealm() {
          return Realm.GetInstance(androidPath);
      }
  
      public void closeRealm(Realm realm) {
          realm.Close();
      }
  
      public Transaction insertCreditCard(EasyVending.CreditCard creditCard) {
          var realm = getRealm();
          using(var transaction = realm.BeginWrite()) {
              var insertedCreditCard = realm.CreateObject&lt;RCreditCard&gt;();
  
              insertedCreditCard.holderName = creditCard.HolderName;
              insertedCreditCard.bandeira = creditCard.CreditCardBrand;
              insertedCreditCard.digitos = creditCard.MaskedCreditCardNumber;
              insertedCreditCard.token = creditCard.InstantBuyKey;
  
              transaction.Commit();
              closeRealm(realm);
              return transaction;
          }
      }
  
      public Transaction removeCreditCard() {
          var realm = getRealm();
          using(var transaction = realm.BeginWrite()) {
              realm.RemoveAll&lt;RCreditCard&gt;();
              transaction.Commit();
              closeRealm(realm);
              return transaction;
          }
      }
  
      public CreditCard getCreditCard() {
          var realm = getRealm();
          var rCreditCard = realm.All&lt;RCreditCard&gt;().First();
          closeRealm(realm);
          var creditCard = new CreditCard() {
              CreditCardBrand = rCreditCard.bandeira,
              MaskedCreditCardNumber = rCreditCard.digitos,
              HolderName = rCreditCard.holderName
          };
          return creditCard;
      }
  
      public bool hasCreditCard() {
          bool answer = false;
          var realm = getRealm();
          if(realm.All&lt;RCreditCard&gt;().Count() &gt; 0) {
              answer = true;
          }
          closeRealm(realm);
          return answer;
      }
  }
  </code></pre>
  
  <p>The error occurs when I try to access any attribute of the RCreditCard object returned by my query:</p>
  
  <pre><code>CreditCardBrand = rCreditCard.bandeira,
  </code></pre>
  
  <p>from</p>
  
  <pre><code>var rCreditCard = realm.All&lt;RCreditCard&gt;().First();
  </code></pre>
  
  <p>Please let me know if the question was not clear enough.</p>