I am using VS2012 and my project is 4.0, but I want to use the async/await keywords, so I install Microsoft.Bcl.Async.
I try to implement my async method in the following way:
public async Task<bool> myMethodAync(int paramInteger)
{
//my code, a simple code that return a bool. Is only an example
if(paramInteger == 2)
{
return true;
}
else return false;
}
I get an error and I get marked the name of the method and the error says something like this: it is not find all the types needed for the modify async. is it the target of the project a wrong version or is it missing the reference for some assembly?
I have the reference for the three assemblies Microsoft.Threading.Task, Microsoft.Threading.Task.Extensions and Microsoft.Threading.Task.Extensions.Desktop and I have the using in my class, System.Threading.task.
What else I need to do?
Thanks.
From http://michaelmairegger.wordpress.com/2012/09/19/cannot-find-all-types-required-by-the-async-modifier/:
The solution to this problem is to reference following nuGet package into all projects in which you want to use the ‘async’ and ‘await’ keyword.
Microsoft.CompilerServices.AsyncTargetingPackSo, right click on
References, then selectManage NuGet Packages..., then search online. You may find the package under the name Async Targeting Pack for Visual Studio 11. Install it and the problem should be solved.