Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top