Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Threading.Tasks.Task Method Not Found

Developing an application and use two different machines. As far as I know, they are both at the same release of Windows 10 (1803). Just recently, I have started having an issue on one machine. The application uses Individual Account Authentication, and at the login prompt, once a user enters their username and password and clicks Login, it throws the following error:

Method not found: 'System.Threading.Tasks.Task`1<!!0> System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(System.Linq.IQueryable`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<!!0,Boolean>>)'.

The code that it identifies as the issue is (at last line):

// To enable password failures to trigger account lockout, change to shouldLockout: true
//var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); // <-- this line

I have went as far as to completely delete the Project from the suspect machine and re-clone from Git, but the same issue. I went thru my references and compared against the machine that it is working on and they all match.

Just for reference, here is the stack trace:

[MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<!!0> System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(System.Linq.IQueryable`1<!!0>, System.Linq.Expressions.Expression`1<System.Func`2<!!0,Boolean>>)'.]
   Microsoft.AspNet.Identity.EntityFramework.<GetUserAggregateAsync>d__6c.MoveNext() +0
   System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start(TStateMachine& stateMachine) +94
   Microsoft.AspNet.Identity.EntityFramework.UserStore`6.GetUserAggregateAsync(Expression`1 filter) +146
   Microsoft.AspNet.Identity.EntityFramework.UserStore`6.FindByNameAsync(String userName) +537
   Microsoft.AspNet.Identity.UserManager`2.FindByNameAsync(String userName) +56
   Microsoft.AspNet.Identity.Owin.<PasswordSignInAsync>d__29.MoveNext() +104
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24
   CaseNotesPlus.Controllers.<Login>d__12.MoveNext() in D:\Projects\CaseNotesPlus\CaseNotesPlus\Controllers\AccountController.cs:88
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
   System.Web.Mvc.Async.<>c__DisplayClass8_0.<BeginInvokeAsynchronousActionMethod>b__1(IAsyncResult asyncResult) +17
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0() +50
   System.Web.Mvc.Async.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +228
   System.Web.Mvc.Async.<>c__DisplayClass7_0.<BeginInvokeActionMethodWithFilters>b__1(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__3() +35
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
   System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9874329
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159

I have verified that I have the same NET Framework Setup on both machines: Version Information:

  • Microsoft .NET Framework Version: 4.0.30319
  • ASP.NET Version: 4.7.3056.0
  • The project targets 4.6.1
like image 537
Keith Clark Avatar asked Jun 07 '18 18:06

Keith Clark


1 Answers

Ensure that you are using Entity Framework version 6.2

I had the same issue because I was using the Linq method FirstOrDefaultAsync() with a version of EntityFramework 6.1.3 (before 6.2.0)

According to Microsoft documentation on "QueryableExtensions.FirstOrDefaultAsync()" : https://docs.microsoft.com/en-us/dotnet/api/system.data.entity.queryableextensions.firstordefaultasync?view=entity-framework-6.2.0

This method is only available with the version of ** EntityFramework 6.2 **

Applies to

Entity Framework

6.2.0

like image 82
Charles SB Avatar answered Oct 11 '22 03:10

Charles SB