# 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 10.12.0.12 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)
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).
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/10.12.0.12/src/mono/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:744
at Microsoft.CSharp.RuntimeBinder.BinderHelper.IsComObject (System.Object obj) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.12/src/mono/external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs:162
at Microsoft.CSharp.RuntimeBinder.BinderHelper.IsDynamicallyTypedRuntimeProxy (System.Dynamic.DynamicMetaObject argument, Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo info) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.12/src/mono/external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs:214
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/10.12.0.12/src/mono/external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs:253
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/10.12.0.12/src/mono/external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs:64
at Microsoft.CSharp.RuntimeBinder.CSharpInvokeConstructorBinder.Bind (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject args) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.12/src/mono/external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpInvokeConstructorBinder.cs:41
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/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Dynamic/DynamicMetaObjectBinder.cs:90
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/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSiteBinder.cs:129
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/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSiteOps.cs:157
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/10.12.0.12/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
--- 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/10.12.0.12/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:174
at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs:333
at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63
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/10.12.0.12/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightLambda.Generated.cs:107
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
Fixed with version Xamarin.iOS 10.12.0.14 (beta) This bug can be closed.
I thought it was fixed but after 2 tries it started again.
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 ?
Yes of course, will see if I can give you guys a simple test call / project.
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.
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
@@ -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.
@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).
I am glad you reproduced the issue and could even pinpoint it. :) Makes me hopeful again thanks, @Sebastien.
Fixed in mono master and 2017-06 branch.
Needs XI/XA mono bump
The fix is required in 2017-04 to bump.
Merged into 2017-04 too
PR master https://github.com/xamarin/xamarin-macios/pull/2369
@Marek is there no unit tests (or are they disable) that could have catch this on bots ?
There are assemblies which are not tested with XI at all like Microsoft.CSharp.dll
I filled a bug report  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.
Possible XM duplicate - https://bugzilla.xamarin.com/show_bug.cgi?id=58296
PR https://github.com/xamarin/xamarin-macios/pull/2369 (master) https://github.com/xamarin/xamarin-macios/commit/e6c8223a8e6bf7ebde17e55e0f47a241dd09f855
PR (d15.4) https://github.com/xamarin/xamarin-macios/pull/2372 merged in https://github.com/xamarin/xamarin-macios/commit/c70e3b572ce9d084967e2e75ca0884b50cefcc3b
Additional tests to be handled in #42656
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 10.14.0.5, 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.
Robert Al Malak
Currently in the alpha channel we have:
10.14.0.3 released on 8-2
QA verified this on 10.14.0.5.
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.
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.
@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?
Robert Al Malak
@Robert this was a timing issue, 10.14.0.3 is in alpha, the fix was in 10.14.0.4 and @Saurabh verifier with 10.14.0.5. 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 10.14.0.5 (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).
*** Bug 58821 has been marked as a duplicate of this bug. ***
PR for d15-3 https://github.com/xamarin/xamarin-macios/pull/2510
*** Bug 58855 has been marked as a duplicate of this bug. ***
## 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 10.12.0.18 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 10.12.0.18 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 https://kb.xamarin.com/customer/portal/articles/1699777-older-downloads.
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 https://bugzilla.xamarin.com/show_bug.cgi?id=58625
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.
@Jacky please do not re-open bugs for a different product, there's a separate bug report for it  and the fixed versions will be mentioned inside it.
## 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 10.12.0.20 in the Xamarin 15.3.2 Servicing Release .
Based on comment#32 and comment#37, marking this bug as verified fixed.