【发布时间】:2014-02-07 16:02:27
【问题描述】:
我正在尝试使用 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?)
我正在为 Windows 桌面使用 VSE 2012,并且肯定安装了 .NET 4.5。我正在参考
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Data.dll
我读过 .NET 4.5 只是替换了 4.0,但是每当我尝试选择 4.5 目录中的 System.Data.dll 时,它都会引用 4.0 中的那个。不确定这是否重要。
【问题讨论】:
-
如果您的项目在 .NET 4.5 上,我测试过它可以工作。您对 .NET 4 使用了错误的 DLL。如果我将项目更改为 .NET 4.0,我会遇到与您相同的异常。
标签: c# .net assemblies