Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TaskAwaiter does not implement INotifyCompletion When Using Visual Studio 2015

I have an old ASP.NET Web Form project that I need to add an async library too. I've upgraded it to .NET Framework v4.5.1. It run and compiles perfectly with Visual Studio 2013.

However, when I open it with Visual Studio 2015, it wont compile. Every async call has a TaskAwaiter does not implement INotifyCompletion error.

For instance, the following code:

public async Task AsyncDelay()
{
    await Task.Delay(1);
}

Throw the following error:

CS4027 'TaskAwaiter' does not implement 'INotifyCompletion'

Any help at all would be appreciated.

like image 912
Dale Alleshouse Avatar asked Dec 10 '15 17:12

Dale Alleshouse


2 Answers

I finally found the issue. This nuget package was installed

https://www.nuget.org/packages/Microsoft.CompilerServices.AsyncTargetingPack/1.0.1

That was there to support older version of Visual Studio. I remove this and everything works.

I wasted way too much time on this one...

like image 170
Dale Alleshouse Avatar answered Nov 15 '22 20:11

Dale Alleshouse


I faced with this issue today, I think it may helps to someone: Microsoft.CompilerServices.AsyncTargetingPack is deprecated, but there is another package

https://www.nuget.org/packages/Microsoft.Bcl.Async

I've removed this from the project, and now everything is fine.

like image 42
sziluetta Avatar answered Nov 15 '22 20:11

sziluetta