正在获取System.InvalidProgramException:无效的IL代码异常

时间:2019-05-17 19:14:17

标签: c# sqlite xamarin.forms entity-framework-core

我有一个使用EF Core 2.2.4和SQLite的Xamarin Forms项目。在我的代码中的许多不同地方,我遇到了一个瞬时错误(可能是1%的时间?),它看起来像是EF Core错误,但我不能肯定地说。

我得到的一个代码示例是:

var context = new DatabaseContext();
var dbItem = await context.MobileErrors.FirstOrDefaultAsync(me => me.Id.Equals(item.Id)).ConfigureAwait(false);

DatabaseContext从DbContext继承。 ToListAsync()和其他EF调用也会发生此异常。例外是:

  

System.InvalidProgramException :(包装中的无效IL代码   动态方法)对象:lambda_method   (System.Runtime.CompilerServices.Closure):方法主体为空。
  在(包装器托管到本地)   System.Delegate.CreateDelegate_internal(System.Type,object,System.Reflection.MethodInfo,bool)   在System.Delegate.CreateDelegate(System.Type类型,System.Object   firstArgument,System.Reflection.MethodInfo方法,System.Boolean   throwOnBindFailure,System.Boolean allowClosed)[0x002f0]在   <58604b4522f748968296166e317b04b4>:0在   System.Delegate.CreateDelegate(System.Type类型,System.Object   firstArgument,System.Reflection.MethodInfo方法)[0x00000]在   <58604b4522f748968296166e317b04b4>:0在   System.Reflection.Emit.DynamicMethod.CreateDelegate(System.Type   代表类型,System.Object目标)[0x0001a]在   <58604b4522f748968296166e317b04b4>:0 at(包装动态方法)   System.Object.lambda_method(System.Runtime.CompilerServices.Closure,Microsoft.EntityFrameworkCore.Query.QueryContext)   在   Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteSingletonAsyncQuery [TResult]   (Microsoft.EntityFrameworkCore.Query.QueryContext queryContext,   System.Func 2[T,TResult] compiledQuery, Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger 1 [TLoggerCategory]   记录器,System.Type contextType)[0x000d6]在   :0处   Mobile.Services.MobileErrorsService.UpdateLocalAsync   (Mobile.Data.Models.DatabaseContext上下文,   Mobile.Data.Models.MobileError项目)[0x00133]在   :0处   Mobile.Services.MobileErrorsService + <> c__DisplayClass8_0.b__0()   [0x00115] in:0

任何有关更改的想法,我都可以尝试解决此问题?谢谢!

0 个答案:

没有答案