我正在尝试使用C#中的TouchDB查询视图。我在这里使用了TouchDB和MonoTouch之间的绑定:https://github.com/mono/monotouch-bindings/tree/master/Couchbase
当调用emit委托方法时,我得到一个“System.Runtime.InteropServices.MarshalDirectiveException”,说“传递给非托管代码的MonoTouch.Foundation.NSObject类型必须具有StructLayout属性。”
我在此处发现此错误报告:https://bugzilla.xamarin.com/show_bug.cgi?id=4781与我的问题类似,但自2012年7月27日以来没有任何更新。
这是我的测试代码:
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) => {
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);
有没有人使用MonoTouch成功查询TouchDB上的视图?谢谢你的帮助