Bug 23483 - Can't use dynamic type in iOS on device, get exception: Object type Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder cannot be converted to target type: System.Object[]
Summary: Can't use dynamic type in iOS on device, get exception: Object type Microsoft...
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2014-09-30 06:36 UTC by leslie.godwin
Modified: 2014-11-26 11:21 UTC (History)
8 users (show)

Is this bug a regression?: ---
Last known good build:

Example project (310.09 KB, application/zip)
2014-09-30 06:36 UTC, leslie.godwin

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description leslie.godwin 2014-09-30 06:36:44 UTC
Created attachment 8252 [details]
Example project

Description of Problem:

Can't use dynamic type in iOS on device.
It works on the simulator though.

Steps to reproduce the problem:
1. create a dynamic variable.
2. assign to an object.
3. invoke a method on the dynamic.

Actual Results:

2014-09-30 12:30:26.318 DynamicBug[2779:1020307] System.ArgumentException: Object type Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder cannot be converted to target type: System.Object[]
  at System.Reflection.Binder.ConvertValue (System.Object value, System.Type type, System.Globalization.CultureInfo culture, Boolean exactMatch) [0x0005a] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Binder.cs:95 
  at System.Reflection.Binder.ConvertValues (System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, Boolean exactMatch) [0x0004e] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Binder.cs:81 
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00014] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:209 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:114 
  at Microsoft.Scripting.Interpreter.MethodInfoCallInstruction.InvokeWorker (System.Object[] args) [0x00010] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.Scripting.Interpreter.MethodInfoCallInstruction.Invoke (System.Object[] args) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.Scripting.Interpreter.MethodInfoCallInstruction.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0003b] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0001b] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/ 

How often does this happen? 

All the time:

Additional Information:

Example code:

public override void ViewDidLoad()

    dynamic x = this;
    x.Title = "DOES NOT WORK!";
Comment 1 Udham Singh 2014-09-30 07:46:35 UTC
I have checked this issue with the sample project attached in bug description and observed the same behaviour mentioned in bug.

Screencast : http://www.screencast.com/t/XmayN7w0

Application Output : https://gist.github.com/Udham1/243abc7654dda1362cb4

Environment Info :

=== Xamarin Studio ===

Version 5.4 (build 240)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
    Mono 3.8.0 ((no/45d0ba1)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 308000009

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 8bd8158
Build date: 2014-09-18 09:12:55-0400

=== Build Information ===

Release ID: 504000240
Git revision: 01786bc67c7024ec33d327ed27e4416d7a846f4e
Build date: 2014-09-17 10:58:48-04
Xamarin addins: 7cd7dfcd6b7b7b53281508954ec080f1cd153ad3

=== Operating System ===

Mac OS X 10.9.4
Darwin Xamarin76s-Mac-mini.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 2 leslie.godwin 2014-09-30 08:26:07 UTC
I re-tested this with the latest Xamarin Beta 5.5 (222).
Still happens.
Comment 4 Michele Tameni 2014-11-10 04:38:38 UTC
Still happening even here, quite annoying as it works as expected in the simulator.
Comment 5 Ian 2014-11-17 19:32:48 UTC
I have the same issue.

To repro 

dynamic foo new ExpandoObject();
foo.GGG = "gggg";
string f = Json.JsonConvert.SerializeObject(foo);

Use f then in a Rest call in an await
Comment 6 Marek Safar 2014-11-20 10:19:42 UTC
Fixed in master.

Note: you will most likely have to manually mark methods/properties called on dynamic instance otherwise linker will remove them.
Comment 7 narayanp 2014-11-26 11:21:42 UTC
Unable to verify as I am getting another issue 24860 while verifying this issue.