Bug 32180 - IOS System.NotImplementedException: The requested feature is not implemented. in Linq Expression
Summary: IOS System.NotImplementedException: The requested feature is not implemented....
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 8.10
Hardware: PC Windows
: Normal normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-07-21 04:28 UTC by pwyss2
Modified: 2017-09-11 10:48 UTC (History)
8 users (show)

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

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:
Status:
RESOLVED FIXED

Description pwyss2 2015-07-21 04:28:21 UTC
Hy

This line of code:
IQueryable<PersonResult> query = Ctx.Connection.Query<PersonResult>(sql).AsQueryable();

...gives the following exception on IOS (on Android it works):

Immediate Window:
?ex.ToString()
"System.NotImplementedException: Interpreter of ref types\n  at Microsoft.Scripting.Interpreter.LightCompiler.CompileMethodCallExpression (System.Linq.Expressions.Expression expr) [0x00075] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.3.2/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1283 \n  at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x001ba] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.3.2/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1642 \n  at Microsoft.Scripting.Interpreter.LightCompiler.Compile (System.Linq.Expressions.Expression expr) [0x00008] in //Library/Frameworks/Xamarin.iOS.framework/Versions/8.10.3.2/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1729 \n  at Microsoft.Scripting.Interpreter.LightCompiler.CompileTop (System.Linq.Expressions.LambdaExpression node) [0x00055] in //Library/Frameworks/Xamarin.iOS

.framework/Versions/8.10.3.2/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:221 \n  at Microsoft.Scripting.Interpreter.LightCompiler.CompileLambdaExpression (System.Linq.Expressions.Expression expr) [0x0000e] in...

Output Window:
System.NotImplementedException: The requested feature is not implemented.
2015-07-17 19:37:34.816 MobileAppiOS[26641:1179560] Unhandled managed exception:
The requested feature is not implemented. (System.NotImplementedException)
...


When I change the code to:
var query = from person in Ctx.Connection.Query<PersonResult>(sql) select new PersonResult() { PersonID = person.PersonID //etc. list of all properties };

...it works on IOS too.

Is this a Bug?

Thanks for your help.

Kind regards,
Peter
Comment 1 Sebastien Pouliot 2015-07-21 08:59:29 UTC
> Is this a Bug?

It's more of a limitation as it's not possible to generate code at runtime [1] on iOS (Apple restriction) and this force us to do expressions with an interpreter (which is not the case for Android or Mono).

Yet it might be possible to fix this case (in the interpreter) -> Marek

[1] http://developer.xamarin.com/guides/ios/advanced_topics/limitations/#No_Dynamic_Code_Generation
Comment 2 David Karlaš 2016-01-20 22:45:10 UTC
This is also problem in EntityFramework 7: https://gist.github.com/DavidKarlas/b70fa4b9ed3fbeba4738
Comment 3 David Karlaš 2016-01-21 07:29:54 UTC
maybe EF7 case can fixed with better if check… ​based on my very limited testing…​ only time that exception is problem in EF is when https://github.com/aspnet/EntityFramework/blob/79f3d4e93f/src/EntityFramework.Core/Storage/ValueBuffer.cs#L61 method is called, as comment says in Mono code https://github.com/mono/mono/blob/1c6d79067/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs#L1278-L1279 we throw exception there just because we can’t handle setting value in ValueTypes, but exception in case of EF is thrown when getter is called… if we just add  to not throw exception if method.Attributes.HasFlag(SpecialName) && method.Name.StartsWith(“get_”) is true, EF will probably work… Notice that developers can still set values in getter...
Comment 4 Jon Douglas [MSFT] 2016-12-28 01:58:04 UTC
Here is a test case with EF 7 and a similar exception based on trying to use EF Core on Xamarin.iOS.

Exception:

https://gist.github.com/JonDouglas/09e57ec6312e9a421937c10f6ae60987

Reproduction:

https://www.dropbox.com/s/e9uz1dtaz0rgt43/EntityFrameworkXamarin.zip?dl=0
Comment 5 Marek Safar 2017-09-11 10:48:22 UTC
Works as expected in recent release