C# ASP NET MVC-无法注册和登录
我已经创建了一个新的ASP NET应用程序。尝试注册时,出现以下错误-找不到方法:C# ASP NET MVC-无法注册和登录,c#,asp.net,asp.net-mvc,entity-framework,missingmethodexception,C#,Asp.net,Asp.net Mvc,Entity Framework,Missingmethodexception,我已经创建了一个新的ASP NET应用程序。尝试注册时,出现以下错误-找不到方法: '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,Boolea
'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>>)'.
问题似乎出现在第155行。在我同事的电脑上,同样的项目运行得非常好。关于如何修复它,有什么想法吗?我见过这种问题偶尔出现在包含多个项目的解决方案中,这些项目引用了程序集的不同版本,其中一个版本有方法,而另一个版本没有。编译项目时,缺少方法的程序集被复制到bin文件夹中,导致代码在运行时无法找到该方法,从而导致此异常 在这种情况下,听起来您可能会遇到类似的情况,我建议您执行以下步骤,看看是否有帮助: 关闭Visual Studio 删除解决方案中所有项目的所有bin和obj文件夹 删除包含已下载nuget软件包的软件包文件夹 重新打开解决方案 确保所有项目都设置为相同的.NET版本,并使用相同的包版本,特别是此问题出现的实体框架 重建解决方案
这里的目标是清除旧版本中可能遗留的任何内容,或者如果某个内容被重命名,等等,并使所有内容恢复到新状态。这不是一条完整的异常消息。你也可以发布异常消息文本吗?我们还可能需要在UserManager中查看一些代码。就你的问题而言,我们没有足够的信息来回答你的问题。我想这是MissingMethodException?如果是这样,FirstOrDefault仅在NET4.5实体框架程序集中可用,因此您需要更新到该程序集。我发布了完整的异常消息这是否回答了您的问题?Linq方法仅在EntityFramework 6.2版本中可用。请确保您使用的是实体框架版本6.2。不幸的是,问题仍然存在
System.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>>)'.
[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__67.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) +525
Microsoft.AspNet.Identity.UserManager`2.FindByNameAsync(String userName) +56
Microsoft.AspNet.Identity.<ValidateUserName>d__14.MoveNext() +380
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
Microsoft.AspNet.Identity.<ValidateAsync>d__13.MoveNext() +262
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
Microsoft.AspNet.Identity.<CreateAsync>d__73.MoveNext() +517
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
Microsoft.AspNet.Identity.<CreateAsync>d__79.MoveNext() +442
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +29
Project.Controllers.<Register>d__15.MoveNext() in C:\Users\Mateusz\Documents\Visual Studio 2015\Projects\testt\test3\Project\Project\Controllers\AccountController.cs:155
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(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__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(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__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(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.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
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) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
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.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
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() +576
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +132
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163
Row 153: {
Row 154: var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
Row 155: var result = await UserManager.CreateAsync(user, model.Password);
Row 156: if (result.Succeeded)
Row 157: {