找不到C#.NET 4.5 ExecuteReaderAsync

Shm*_*opy 0 .net c# assemblies

我正在尝试使用异步查询数据库,ExecuteReaderAsync()但是我收到以下错误:

'System.Data.SqlClient.SqlCommand' does not contain a definition for 
'ExecuteReaderAsync' and no extension method 'ExecuteReaderAsync' accepting a first
argument of type 'System.Data.SqlClient.SqlCommand' could be found (are you missing a 
using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

我正在使用VSE 2012 for Windows Desktop并且.NET 4.5已经安装.我正在引用

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.dll
Run Code Online (Sandbox Code Playgroud)

我已经读过.NET 4.5只是替换4.0,但每当我尝试在4.5目录中选择System.Data.dll时,它都会引用4.0中的那个.不确定是否重要.

Ric*_*ard 5

不确定是否重要.

正如在4.5ExecuteReaderAsync添加的那样,我认为它确实如此!

  1. 确保您的项目设置为在其项目设置中使用.NET 4.5.

  2. 在添加4.5引用之前,请确保删除任何早期引用.