This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 57919 - dynamic object is not supported
Summary: dynamic object is not supported
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries (show other bugs)
Version: XI 10.12 (d15-3)
Hardware: Macintosh Mac OS
: High blocker
Target Milestone: 15.3
Assignee: Bugzilla
: 58821 58855 (view as bug list)
Depends on:
Reported: 2017-07-03 22:47 UTC by robertalmalak7
Modified: 2017-09-18 22:02 UTC (History)
20 users (show)

See Also:
Is this bug a regression?: Yes
Last known good build: XI 10.10 (mono 2017-02)

DynamicResponse object which throws OperationNotSupported (14.71 KB, application/zip)
2017-07-18 20:42 UTC, robertalmalak7

Description robertalmalak7 2017-07-03 22:47:17 UTC
# Steps to reproduce
1. Download ElasticSearch.Net from nuget (5.4.0)
2. use any call with lowlevelclient with return type DynamicResponse (DynamicResponse is a dictionary with <string, dynamic> )
3. Exception is thrown saying that platform not supported (usually this indicates that Xamarin.iOS has the limitation with dynamic types.) 

# Expected behavior
Not sure. DynamicResponse was working in previous versions of Xamarin.iOS. However with Beta version it causes the dynamic types within DynamicResponse to throw an exception. 

# Actual behavior
Throws exception platform not supported

# Supplemental info (logs, images, videos)
Here is the DynamicResponse class it will throw on line 40 where it tried to set an object to a dynamic type. However, this worked in previous versions of Xamarin.iOS.

# Test environment (full version information)
Comment 1 Timothy Risi 2017-07-05 22:25:02 UTC
Please include your full build logs, crash reports (if any), test case (to reproduce) and all version information.

To get full build logs just set the log verbosity to diagnostic at the following locations:
- On Visual Studio for Mac: Preferences > Projects > Build
- On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run

On Visual Studio Windows you also want to add `-v -v -v -v` to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting `Properties`.
Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

Easiest way to get exact version information:
- On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
- On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.
Then copy/paste the version information (you can use the "Copy Information" button).
Comment 2 robertalmalak7 2017-07-10 23:53:15 UTC
Sorry forgot to add the logs: 

2017-07-10T23:47:48.6967250Z Exception while emitting periodic batch from Serilog.Sinks.Elasticsearch.ElasticsearchLogShipper: Elasticsearch.Net.UnexpectedElasticsearchClientException: Operation is not supported on this platform. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
  at System.Runtime.InteropServices.Marshal.IsComObject (System.Object o) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.CSharp.RuntimeBinder.BinderHelper.IsComObject (System.Object obj) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.CSharp.RuntimeBinder.BinderHelper.IsDynamicallyTypedRuntimeProxy (System.Dynamic.DynamicMetaObject argument, Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo info) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.CSharp.RuntimeBinder.BinderHelper.DeduceArgumentRestriction (System.Int32 parameterIndex, Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder callPayload, System.Dynamic.DynamicMetaObject argument, Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo info) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind (System.Dynamic.DynamicMetaObjectBinder action, Microsoft.CSharp.RuntimeBinder.RuntimeBinder binder, System.Dynamic.DynamicMetaObject[] args, System.Collections.Generic.IEnumerable`1[T] arginfos, System.Dynamic.DynamicMetaObject onBindingError) [0x000a3] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Microsoft.CSharp.RuntimeBinder.CSharpInvokeConstructorBinder.Bind (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject[] args) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Dynamic.DynamicMetaObjectBinder.Bind (System.Object[] args, System.Collections.ObjectModel.ReadOnlyCollection`1[T] parameters, System.Linq.Expressions.LabelTarget returnLabel) [0x000c6] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T] (System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00019] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Runtime.CompilerServices.CallSiteOps.Bind[T] (System.Runtime.CompilerServices.CallSiteBinder binder, System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at System.Linq.Expressions.Interpreter.LightLambda.Run3[T0,T1,T2,TRet] (T0 arg0, T1 arg1, T2 arg2) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
  at Elasticsearch.Net.DynamicResponse.set_Item (System.String name, System.Object value) [0x0004e] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.DynamicResponse.Create (System.Collections.Generic.IDictionary`2[TKey,TValue] values) [0x00024] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.ElasticsearchNetJsonStrategy.DeserializeObject (System.Object value, System.Type type) [0x00027] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.SimpleJson.DeserializeObject (System.String json, System.Type type, Elasticsearch.Net.IJsonSerializerStrategy jsonSerializerStrategy) [0x00025] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.SimpleJson.DeserializeObject[T] (System.String json, Elasticsearch.Net.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.ElasticsearchDefaultSerializer.Deserialize[T] (System.IO.Stream stream) [0x0003b] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.ResponseBuilder`1[TReturn].SetBody (Elasticsearch.Net.ElasticsearchResponse`1[T] response, System.IO.Stream stream) [0x000b0] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.ResponseBuilder`1[TReturn].ToResponse () [0x00023] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.HttpConnection.Request[TReturn] (Elasticsearch.Net.RequestData requestData) [0x00080] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.RequestPipeline.CallElasticsearch[TReturn] (Elasticsearch.Net.RequestData requestData) [0x0008b] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.Transport`1[TConnectionSettings].Request[TReturn] (Elasticsearch.Net.HttpMethod method, System.String path, Elasticsearch.Net.PostData`1[T] data, Elasticsearch.Net.IRequestParameters requestParameters) [0x000b6] in <b232b808702945828f072dbb6f80bcbd>:0 
   --- End of inner exception stack trace ---
  at Elasticsearch.Net.Transport`1[TConnectionSettings].Request[TReturn] (Elasticsearch.Net.HttpMethod method, System.String path, Elasticsearch.Net.PostData`1[T] data, Elasticsearch.Net.IRequestParameters requestParameters) [0x00140] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.ElasticLowLevelClient.DoRequest[T] (Elasticsearch.Net.HttpMethod method, System.String path, Elasticsearch.Net.PostData`1[T] data, Elasticsearch.Net.IRequestParameters requestParameters) [0x00006] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Elasticsearch.Net.ElasticLowLevelClient.Bulk[T] (Elasticsearch.Net.PostData`1[T] body, System.Func`2[T,TResult] requestParameters) [0x00021] in <b232b808702945828f072dbb6f80bcbd>:0 
  at Serilog.Sinks.Elasticsearch.ElasticsearchLogShipper.OnTick () [0x00161] in <c2d68fae346743aaa94747da85eb0621>:0
Comment 3 robertalmalak7 2017-07-13 00:11:19 UTC
Fixed with version Xamarin.iOS (beta) This bug can be closed.
Comment 4 robertalmalak7 2017-07-13 16:40:00 UTC
I thought it was fixed but after 2 tries it started again.
Comment 5 Sebastien Pouliot 2017-07-17 15:02:10 UTC
This might be due to an update of the BCL (that's where the stack trace points to). 

@Marek my guess is that

> System.Runtime.InteropServices.Marshal.IsComObject (System.Object o) 

should not throw a `PlatformNotSupportedException` and simply return false (which I assume would allow the code to run as expected).

But that might not be the only issue.

@Robert Can you please share a test case that duplicate this ?
Comment 6 robertalmalak7 2017-07-18 19:55:04 UTC
Yes of course, will see if I can give you guys a simple test call / project.
Comment 7 robertalmalak7 2017-07-18 20:42:12 UTC
Created attachment 23643 [details]
DynamicResponse object which throws OperationNotSupported

Here is a Xamarin.iOS project. I put all the code in finished launching and I just created a new DynamicResponse and added new value to it. That's basically mimicking the same thing as doing a call to bulk API with elasticsearch and returning a DynamicResponse. When running the app it will throw the same OperationNotSupported exception. 

So I know there are limitations with dynamic type, however, how did it work in previous versions of Xamarin.iOS.
Comment 8 Sebastien Pouliot 2017-07-20 00:59:49 UTC
Thanks for providing a test case!

First quick look it seems that the recent (CoreFX version) of `System.Linq.Expressions.Interpreter` calls mono's `IsComObject`. The later has not have changed (for a long while) but it would seem it block some new (corefx) code paths that your code requires.

Recompiling mscorlib.dll with

diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
index 03eda1eea08..128b8c983b1 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
@@ -741,7 +741,7 @@ namespace System.Runtime.InteropServices
                public static bool IsComObject (object o)
-                       throw new PlatformNotSupportedException ();
+                       return false;

makes the test case works... well it does not throw anymore.
Comment 9 Sebastien Pouliot 2017-07-20 01:24:08 UTC
@Alex tested the attached sample and it works fine in XI 10.10. It would seem the issue started in 10.12 (which switched from mono 2017-02 to 2017-04).
Comment 10 robertalmalak7 2017-07-20 05:14:35 UTC
I am glad you reproduced the issue and could even pinpoint it. :) Makes me hopeful again thanks, @Sebastien.
Comment 11 Miguel de Icaza [MSFT] 2017-07-20 15:21:01 UTC
Comment 12 Marek Safar 2017-07-25 15:11:43 UTC
Fixed in mono master and 2017-06 branch.

Needs XI/XA mono bump
Comment 13 Sebastien Pouliot 2017-07-25 15:18:23 UTC
The fix is required in 2017-04 to bump.
Comment 14 Marek Safar 2017-07-25 15:21:20 UTC
Merged into 2017-04 too
Comment 15 Sebastien Pouliot 2017-07-25 15:27:10 UTC
PR master

@Marek is there no unit tests (or are they disable) that could have catch this on bots ?
Comment 16 Marek Safar 2017-07-25 16:19:59 UTC
There are assemblies which are not tested with XI at all like Microsoft.CSharp.dll

I filled a bug report [0] about it over year ago and Vincent made it enhancement and you postponed several times. I don't know reasoning for that.
Yes, we could catch it but as we don't run the available tests on XI we didn't.

Comment 17 Chris Hamons 2017-07-31 20:59:35 UTC
Possible XM duplicate -
Comment 20 robertalmalak7 2017-08-07 17:27:42 UTC
Hi everyone, 

So I finally saw that the fix was released in the alpha channel.

"57919 - [bcl] Dynamic object is not supported"

But when I tried the sample project it still failed. Looking at @Saurabh comment I see that he was using the, does this mean this might be miss-stated in the alpha releases and that I can expect it in next release? 

Also after upgrading this error also happens now for Android. 

Kind regards,
Robert Al Malak
Comment 21 Chris Hamons 2017-08-07 17:32:04 UTC
Currently in the alpha channel we have: released on 8-2

QA verified this on

I'm looking into why the release notes are out of sync with current, but this should be fixed on the _next_ Alpha update.

Apologies for the confusion.
Comment 22 Chris Hamons 2017-08-07 17:48:16 UTC
It appears it may be awhile until .5 or later make it to Alpha, so if you are dead in the water on Alpha, you can try this version:

It doesn't have the full QA pass that our releases have, but since it is on a release branch it should likely be safe to try with little chance of regression.
Comment 23 robertalmalak7 2017-08-07 18:00:09 UTC
@Chris we are very near a release and it would be great to know when this fix would be in the Stable channel. Any ETA? Is there any way we could push this fix separate and put it into stable? 

Kind regards,
Robert Al Malak
Comment 24 Sebastien Pouliot 2017-08-08 16:35:24 UTC
@Robert this was a timing issue, is in alpha, the fix was in and @Saurabh verifier with I'll update our release notes since it seems to have leaked a bit early.

Our next alpha (due soon, we try to refresh weekly) will have the fix for this bug. However our next milestone (15.4) is scheduled for stable this fall.

If you're releasing before this I suggest you to use (from the link that Chris gave you in comment #22). It's nearly identical to the latest 10.12 (which is locked and going stable soon) since most of our current work is for Xcode 9 (and done in a different branch).
Comment 27 Rolf Bjarne Kvinge [MSFT] 2017-08-17 08:27:10 UTC
*** Bug 58821 has been marked as a duplicate of this bug. ***
Comment 28 Sebastien Pouliot 2017-08-18 15:01:39 UTC
PR for d15-3
Comment 29 Sebastien Pouliot 2017-08-18 19:26:26 UTC
*** Bug 58855 has been marked as a duplicate of this bug. ***
Comment 30 Brendan Zagaeski (Xamarin Support) 2017-08-19 00:06:46 UTC
## Experimental installer package available for Xamarin.iOS 10.12 versions

The following experimental quality installer package includes the candidate fix for this issue.  Be advised that this package has not been through any QA testing, but it did successfully stop the problem in my local tests for the scenario described in Comment 7 (both in Visual Studio for Mac and in Visual Studio 2017 on Windows).

Download the following package onto your Mac and double-click it in Finder to run the installer:

Because this is an experimental version installed outside of the updater channels mechanism, Visual Studio for Mac will continue to offer an "update" back to the _older_ published Stable updater channel versions when you have this version installed.  You will need to ignore that notification if you wish to keep using this experimental version.

## Steps to switch back to the current published version

If any users need to switch back to the current published version Xamarin.iOS after trying this experimental version, you can do so using either of the following methods:

- Check for updates on the Stable updater channel within Visual Studio for Mac on your Mac.  At the moment, this will offer you the original version of Xamarin.iOS.  (Note that in the near future, after additional testing and approvals, the candidate fixes will also be published to the Stable updater channel.)


- Manually download and run the individual older Xamarin.iOS installer package as described on
Comment 31 Omar 2017-08-20 08:51:41 UTC
Thank you @Brenden, This does fix the issue in iOS indeed. I downloaded and run the package on my Mac and I also updated my VS2017 to 15.3.1 on windows, then I cleaned and rebuilt the project and it worked.

But the issue is still on Android, is there a similar fix for Android?
Please check
Comment 35 Nino Padrutt 2017-08-22 08:01:31 UTC
Is there a date when such a fix will be arrive in VS? And as @mar already asked: is there an work around for android? I'm currently totally blocked through that issue.
Comment 36 Sebastien Pouliot 2017-08-22 18:11:52 UTC
@Jacky please do not re-open bugs for a different product, there's a separate bug report for it [1] and the fixed versions will be mentioned inside it.

Comment 37 Brendan Zagaeski (Xamarin Support) 2017-08-22 22:28:13 UTC
## Status update for any users watching this issue

The candidate fix for this issue has now been published to the Stable and Beta updater channels as part of Xamarin.iOS in the Xamarin 15.3.2 Servicing Release [1].

Comment 38 GouriKumari 2017-08-25 15:57:52 UTC
Based on comment#32 and comment#37, marking this bug as verified fixed.

Note You need to log in before you can comment on or make changes to this bug.