Newtonsoft.Json dynamic exception only in IOS/Device/Release

ZoliZoli NLMember ✭✭✭
edited January 28 in Xamarin.Forms

Hi,

My Xamarin.Forms app throws exception: Microsoft.CSharp.Runtime-Binder.RuntimeBinderException: Cannot apply indexing with [] to an expression of type "Newtonsoft.Json.Linq.Jobject"
This only happens in the iOS release version installed on device (either by Xamarin on my device, or from Apple Store by customers).
It works fine on Android (same code!), also tested on iOS Simulator, both Debug and Release - works fine.

The code is here (2nd line):

dynamic json = JObject.Parse(message);
long time = (long)(json["timestamp"]);

I am using Newtonsoft.Json 11.0.2 (not the latest)

Any idea? Maybe some release mode optimizer removes something what should not be removed?

Thanks

Best Answer

  • ZoliZoli NL ✭✭✭
    Accepted Answer

    I got the answer:

    From the Xamarin.iOS documentation

    Since the iOS kernel prevents an application from generating code dynamically, Xamarin.iOS does not support any form of dynamic code generation.

    According to this blog entry this includes the use of the dynamic type. For reasons (that are not necessarily important for the scope of this answer).

Answers

  • ZoliZoli NLMember ✭✭✭
    Accepted Answer

    I got the answer:

    From the Xamarin.iOS documentation

    Since the iOS kernel prevents an application from generating code dynamically, Xamarin.iOS does not support any form of dynamic code generation.

    According to this blog entry this includes the use of the dynamic type. For reasons (that are not necessarily important for the scope of this answer).

Sign In or Register to comment.