문제

I'm trying to query a database asynchronously using ExecuteReaderAsync() but I get the following error:

'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?)

I'm using VSE 2012 for Windows Desktop and .NET 4.5 is definitely installed.I'm referencing

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

I've read that .NET 4.5 just replaces 4.0, but whenever I try to select the System.Data.dll in the 4.5 directory, it references the one in 4.0. Not sure if that matters.

도움이 되었습니까?

해결책

Not sure if that matters.

As ExecuteReaderAsync was added in 4.5 I rather think it does!

  1. Ensure your project is set to use .NET 4.5 in its project settings.

  2. Before adding the 4.5 reference ensure you remove any earlier references.

다른 팁

Choose the project properties and set the Target framework to .NET Framework 4.5 and not the client profile.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top