我更新到VS 2017 15.3和VS Mac 7.1以及Xamarin.Android 7.4。从那以后,几乎所有我的EF Core查询都不再起作用了,应用程序崩溃了Exception System.PlatformNotSupportedException。
消息是:
Operation is not supported on this platform.
这是我激活诊断日志时获得的堆栈跟踪:
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.PlatformNotSupportedException: Operation is not supported on this platform.
[MonoDroid] at System.Runtime.InteropServices.Marshal.IsComObject (System.Object o) [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Microsoft.CSharp.RuntimeBinder.BinderHelper.IsComObject (System.Object obj) [0x00003] in <0c600cab29754882aa1761854aaa8abf>:0
[MonoDroid] at Microsoft.CSharp.RuntimeBinder.BinderHelper.IsDynamicallyTypedRuntimeProxy (System.Dynamic.DynamicMetaObject argument, Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo info) [0x00011] in <0c600cab29754882aa1761854aaa8abf>:0
[MonoDroid] at Microsoft.CSharp.RuntimeBinder.BinderHelper.DeduceArgumentRestriction (System.Int32 parameterIndex, Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder callPayload, System.Dynamic.DynamicMetaObject argument, Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo info) [0x00011] in <0c600cab29754882aa1761854aaa8abf>:0
[MonoDroid] 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 <0c600cab29754882aa1761854aaa8abf>:0
[MonoDroid] at Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject[] args, System.Dynamic.DynamicMetaObject errorSuggestion) [0x0000e] in <0c600cab29754882aa1761854aaa8abf>:0
[MonoDroid] at System.Dynamic.InvokeMemberBinder.FallbackInvokeMember (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject[] args) [0x00000] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Dynamic.DynamicMetaObject.BindInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Dynamic.DynamicMetaObject[] args) [0x0000b] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Dynamic.InvokeMemberBinder.Bind (System.Dynamic.DynamicMetaObject target, System.Dynamic.DynamicMetaObject[] args) [0x00016] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Dynamic.DynamicMetaObjectBinder.Bind (System.Object[] args, System.Collections.ObjectModel.ReadOnlyCollection`1[T] parameters, System.Linq.Expressions.LabelTarget returnLabel) [0x000c6] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T] (System.Runtime.CompilerServices.CallSite`1[T] site, System.Object[] args) [0x00019] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0, T1 arg1) [0x000fc] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Storage.RelationalSqlGenerationHelper.GenerateLiteral (System.Object value, Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping typeMapping) [0x00086] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitConstant (System.Linq.Expressions.ConstantExpression expression) [0x0002a] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at System.Linq.Expressions.ConstantExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00005] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit (System.Linq.Expressions.Expression expression) [0x0003f] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitBinary (System.Linq.Expressions.BinaryExpression expression) [0x0012d] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at System.Linq.Expressions.BinaryExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00005] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit (System.Linq.Expressions.Expression expression) [0x0003f] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitSelect (Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression selectExpression) [0x0015f] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x0001e] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00005] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0
[MonoDroid] at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit (System.Linq.Expressions.Expression expression) [0x0002c] in <0a52ab02a5054a9e94c0cd3993f4d33a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.GenerateSql (System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] parameterValues) [0x00043] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.GetRelationalCommand (System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] parameters) [0x00025] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable+AsyncEnumerator+<BufferlessMoveNext>d__9.MoveNext () [0x0041d] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable+AsyncEnumerator+<MoveNext>d__8.MoveNext () [0x00140] in <1ce4ae811dd94fe5a5e10e630f2f4c7a>:0
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider+SelectAsyncEnumerable`2+SelectAsyncEnumerator+<MoveNext>d__4[TSource,TResult].MoveNext () [0x0006e] in <2645c1c7345546f5b968e91de81e2b12>:0
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider+SelectAsyncEnumerable`2+SelectAsyncEnumerator+<MoveNext>d__4[TSource,TResult].MoveNext () [0x0006e] in <2645c1c7345546f5b968e91de81e2b12>:0
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider+ExceptionInterceptor`1+EnumeratorExceptionInterceptor+<MoveNext>d__5[T].MoveNext () [0x0016e] in <2645c1c7345546f5b968e91de81e2b12>:0
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions+<ToListAsync>d__129`1[TSource].MoveNext () [0x000b7] in <2645c1c7345546f5b968e91de81e2b12>:0
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at ConnectContacts.Service.DataServices.ContactDataService+<GetContactsExceptMe>d__4.MoveNext () [0x00038] in /Users/npadrutt/Documents/GitHub/ConnectContacts/ConnectContacts/ConnectContacts.Service/DataServices/ContactDataService.cs:110
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at ConnectContacts.Business.ViewModels.ContactListViewModel+<LoadData>d__27.MoveNext () [0x00067] in /Users/npadrutt/Documents/GitHub/ConnectContacts/ConnectContacts/ConnectContacts.Business/ViewModels/ContactListViewModel.cs:134
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at ConnectContacts.Business.ViewModels.ContactListViewModel+<ViewAppeared>d__26.MoveNext () [0x00020] in /Users/npadrutt/Documents/GitHub/ConnectContacts/ConnectContacts/ConnectContacts.Business/ViewModels/ContactListViewModel.cs:124
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <183b200ee49746d48fc781625979428e>:0
[MonoDroid] at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <71828dd8fb5f4508815e23d6996c45c2>:0
[MonoDroid] at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <71828dd8fb5f4508815e23d6996c45c2>:0
[MonoDroid] at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <71828dd8fb5f4508815e23d6996c45c2>:0
[MonoDroid] at (wrapper dynamic-method) System.Object:51155536-39dc-466e-a95f-dea6c3e2125b (intptr,intptr)
其中一个错误的查询是:
var list = await contactRepository
.GetAll()
.Where(x => x.IsMe)
.ToListAsync();
当我删除where子句时,它可以工作。
我可以解决的另一个问题是我改变了以下内容:
query.Where(x => x.Infos.Any())
.Where(x => x.Infos.Any(e => e.InfoType.ToString()
.StartsWith("Number", StringComparison.OrdinalIgnoreCase)));
为:
query.Where(x => x.Infos.Any(e => e.InfoType.ToString()
.StartsWith("Number", StringComparison.OrdinalIgnoreCase)));
我使用EF Core 1.1.2和EF Core SQLite 1.1.2。
由于EF Core 2.0有更新,我想也许这可以修复更新。但EF核心只支持Xamarin.Android 7.5,现在还没有。因此无法进行更新..
我和其他有类似论点的开发者交谈过。这里有什么问题,我该如何解决?
答案 0 :(得分:0)