I ran into a lock problem ... I have a project (iOS, in this case) linking to the PCL (made by me), which itself refers to the portable version of Newtonsoft.Json
App → My PCL → Newtonsoft.Json
Everything compiles just fine, but at runtime when using my PCL method that calls Newtonsoft.Json, I get a TypeLoadException
Example: A simple PCL referencing Newtonsoft.Json Portable, with one class like this:
public class MyClass {
public int Test() {
var json = @"{""t"":16,""s"":""test""}";
var o = JObject.Parse(json);
return o["t"].Value<int>();
}
}
A simple one-button application with this event handler:
partial void Test() {
var c = new MyClass();
var i = c.Test();
new UIAlertView("", i.ToString(), null, "Close").Show();
}
I get a TypeLoadException when I click a button in the line "var i = c.Test ();"
Even stranger if you replace this:
return o["t"].Value<int>();
with this:
return (int)o["t"];
I no longer get a TypeLoadException, but a MissingMemberException, with this message:
Newtonsoft.Json.Linq.JToken:: op_Explicit (JToken) /Users/Ingham/Projects/TestPCL -iOS/TestPCL-iOS/bin/iPhoneSimulator/Debug/Newtonsoft.Json.dll, /Users/Ingham/Projects/TestPCL -iOS/TestPCL/bin/Debug/TestPCL.dll
, ...
PCL, ...
?
!
(Xamarin.iOS):
https://www.dropbox.com/s/lsclrg5d1cor1dk/TestPCL.zip