what do you mean it's not awaitable?

but wait, i've referenced the correct assemblies and all of the method calls are in correct form...so what gives?

paste that message in your browser's search field and you'll find that there are a number of reasons that you might encounter this error. one, rather simple reason, is that i attempted to implement the awaitable pattern in a project where the targeted framework version was not compatible. it appears that the system.threading.tasks implementation of awaitable is different between .net versions 4.0 and 4.5. the following code compiled fine when the project targeted one version of the framework but failed when targeting the other.

.NET 4.0


.NET 4.5

it appears that in .net 4.5, controller methods implement the async/await pattern and return a Task<ActionResult>.


compiler error: some packages targeting a different framework

so don't forget about package updates.

in order to fix the compiler error, i had to target the .net framework version 4.5 in the project properties window as well as update some of the packages. this is because the project was previously targeting .net 4.0, and i was upgrading it to a newer framework that required updating some of the nuget packages. more specifically i had to update entityframework, microsoft.net.http, and some packages related to dotnetopenauth.

as shown below, updating these packages was as simple as running the update-package command in the package manager console.

barring any other unrelated issues, the project is ready to implement the awaitable pattern the .net 4.5 way.

happy coding.


Comments are closed