Method not found: 'System.Type.op_Equality' using MonoTouch

Oct 27, 2011 at 6:06 PM
Edited Oct 27, 2011 at 7:40 PM

Hi,

Perhaps out of scope here and needs to be on MonoTouch forum, but starting MonoDevelop / Monotouch development project using json and during serialization, I receive exception: System.MissingMethodException: Method not found: 'System.Type.op_Equality'...

This exception comes during call to 'Serializer.ContractResolver.ResolveContract(value.GetType())' within method 'GetContractSafe(object value)'

Versions loaded:

Json.NET 4.0 Release 3 (Oct 1), Monodevelop 2.8.1, Mono 2.10.6, Xcode 4.2, ios 5 sdk, Monotouch 5.0

Any thoughts, considerations, concerns appreciated.

Thanks!

Complete stack trace:

System.Threading.Tasks.Task.HandleGenericException (e={System.MissingMethodException: Method not found: 'System.Type.op_Equality'.  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00008] in /Users/jamesphillips/Projects/Json40r3/Source/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:86   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value) [0x00011] in /Users/jamesphillips/Projects/Json40r3/Source/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:70   at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value) [0x00012] in /Users/jamesphillips/Projects/Json40r3/Source/Src/Newtonsoft.Json/JsonSerializer.cs:451   at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value) [0x00000] in /Users/jamesphillips/Projects/Json40r3/Source/Src/Newtonsoft.Json/JsonSerializer.cs:443   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Formatting formatting, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002c] in /Users/jamesphillips/Projects/Json40r3/Source/Src/Newtonsoft.Json/JsonConvert.cs:634   at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in /Users/jamesphillips/Projects/Json40r3/Source/Src/Newtonsoft.Json/JsonConvert.cs:571   at Storyboard_Utility_App.SerializeMe.LoadTheProduct () [0x0005d] in /Users/jamesphillips/Projects/Storyboard_Utility_App/SerializeMe.cs:47   at Storyboard_Utility_App.SerializeMe..ctor () [0x00006] in /Users/jamesphillips/Projects/Storyboard_Utility_App/SerializeMe.cs:35   at Storyboard_Utility_App.MainViewController.<ViewDidLoad>m__0 () [0x00000] in /Users/jamesphillips/Projects/Storyboard_Utility_App/MainViewController.cs:38   at System.Threading.Tasks.TaskFactory+<StartNew>c__AnonStorey15.<>m__A (System.Object o) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/TaskFactory.cs:106   at System.Threading.Tasks.Task.InnerInvoke () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:424   at System.Threading.Tasks.Task.ThreadStart () [0x00039] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:384 }) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading.Tasks/Task.cs:474

Oct 28, 2011 at 1:49 PM

An answer found for those who may need it. 

Json.NET 4.0 Release 3 needs to be rebuilt from source using the 'smcs' compiler provided with MonoTouch. Someone has already done this and can be found on github at: 4.0 r3 for MonoTouch https://github.com/ayoung/Newtonsoft.Json

The smcs compiles referencing MonoTouch' class libraries instead of the desktop class libraries. If you reference the desktop class libraries when compiling you might end up referencing methods that don't exist in MonoTouch (such as System.Type.op_Equality). 

This answer graciously provided by the folks at MonoTouch forum: http://monotouch.2284126.n4.nabble.com/System-MissingMethodException-Method-not-found-System-Type-op-Equality-td3770750.html#a3945599

Cheers!