title: TouchDB Query view throws MarshalDirectiveException
body: <p>I'm trying to query a view using TouchDB in C#. I used the binding between TouchDB and MonoTouch available here : <a href="https://github.com/mono/monotouch-bindings/tree/master/Couchbase" rel="nofollow">https://github.com/mono/monotouch-bindings/tree/master/Couchbase</a></p>
  
  <p>When the emit delegate method is called, I get a "System.Runtime.InteropServices.MarshalDirectiveException" saying "The type MonoTouch.Foundation.NSObject which is passed to unmanaged code must have a StructLayout attribute."</p>
  
  <p>I found this bug report here : <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=4781" rel="nofollow">https://bugzilla.xamarin.com/show_bug.cgi?id=4781</a> that is similar to my problem but there isn't any updates since July 27, 2012.</p>
  
  <p>Here's my test code :</p>
  
  <pre><code>CouchTouchDBServer server = new CouchTouchDBServer ();
  CouchDatabase database = server.GetDatabase ("grocery-sync");
  database.TracksChanges = true;
  
  // Create a test view
  design = database.DesignDocumentWithName ("grocery");
  design.DefineView ("testView", (doc,emit) =&gt; {
      emit (doc, doc); // Crashes here
  }, "1.0");
  
  // Query the view
  CouchQuery query = design.CereateQuery("testView");
  RestOperation op = query.Start();
  string response = op.ResponseBody.AsString;
  Console.WriteLine(response);
  </code></pre>
  
  <p>Has anyone successfully queried a view on TouchDB with MonoTouch? Thanks for your help</p>