C# 未找到方法:';System.Threading.Tasks.Task`System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync

C# 未找到方法:';System.Threading.Tasks.Task`System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync,c#,asp.net,.net,entity-framework,webforms,C#,Asp.net,.net,Entity Framework,Webforms,我使用Visual Studio 2017、.NET 4.6.1和EF 6.2创建了一个Web表单应用程序。无论何时我在本地运行应用程序,它都可以正常工作。但是,当我发布应用程序并将其上载到IIS服务器时,屏幕截图中显示了错误 引用web服务器(而非本地系统)上不存在的文件路径,但是我在VS中找不到任何属性来更改或设置该路径 IIS服务器上运行着另一个web窗体应用程序,其目标是.NET和EF的早期版本。这个应用程序运行良好,但据我所知,在我的应用程序中引起问题的异步方法是在EF的更高版本中引

我使用Visual Studio 2017、.NET 4.6.1和EF 6.2创建了一个Web表单应用程序。无论何时我在本地运行应用程序,它都可以正常工作。但是,当我发布应用程序并将其上载到IIS服务器时,屏幕截图中显示了错误

引用web服务器(而非本地系统)上不存在的文件路径,但是我在VS中找不到任何属性来更改或设置该路径

IIS服务器上运行着另一个web窗体应用程序,其目标是.NET和EF的早期版本。这个应用程序运行良好,但据我所知,在我的应用程序中引起问题的异步方法是在EF的更高版本中引入的


在这个问题上的任何帮助都是非常感谢的,在过去的几天里我一直在绞尽脑汁

在对这个问题进行深入研究之后,我最终创建了一个新的EC2实例。一旦上传,应用程序就可以正常运行。我假设旧实例存在一些配置问题。

您需要在问题中包含相关代码。堆栈跟踪告诉您错误是哪一行。@如果导致错误的代码是默认的.NET/EF授权/身份验证代码,我将使用web窗体身份验证对应用程序的用户进行身份验证。我认为问题不在于代码本身,而在于配置/发布。应用程序在我的本地计算机上按预期编译和运行。它只是在IIS上发布和运行时才会引发异常。@应用程序在服务器上运行,但只要调用任何标准的.NET/EF登录代码,应用程序就会崩溃。我想问题不在EF中,检查您的应用程序池.Net CLR版本,并确保它针对V4。0@AhmedRagheb应用程序池当前的目标是V4.0,服务器安装了.NET 4.6.1
Server Error in '/' Application.
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>>)'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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>>)'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

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) +174
   Microsoft.AspNet.Identity.EntityFramework.UserStore`6.GetUserAggregateAsync(Expression`1 filter) +199
   Microsoft.AspNet.Identity.Owin.<PasswordSignInAsync>d__29.MoveNext() +150
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +13847892
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +61
   Microsoft.AspNet.Identity.AsyncHelper.RunSync(Func`1 func) +212
   SupplierPortal.Account.Login.LogIn(Object sender, EventArgs e) in C:\Users\Kobi\Dropbox\Development\WebForms\SupplierPortal_git\SupplierPortal\Account\Login.aspx.cs:39
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +138
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150
   System.Web.UI.<ProcessRequestMainAsync>d__523.MoveNext() +7834
SupplierPortal.Account.Login.LogIn(Object sender, EventArgs e) in C:\Users\Kobi\Dropbox\Development\WebForms\SupplierPortal_git\SupplierPortal\Account\Login.aspx.cs:39