After adding this method (first test on C# async keyword in my life) to my project I get the error below, why?
public async Task<Member> AddOrUpdate(DownloadFormModel model)
{
IMailChimpManager mailChimpManager = new MailChimpManager(ConfigurationManager.AppSettings["mailChimpKey"]);
Member member = new Member {EmailAddress = model.Email, Status = Status.Subscribed};
member.MergeFields.Add("NAME", model.Name);
return (await mailChimpManager.Members.AddOrUpdateAsync(ConfigurationManager.AppSettings["mailChimpDownloadListID"], member));
}
Error inside VStudio 2015 after compilation:
Missing compiler required member 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AwaitOnCompleted'
My project is a ASP.NET MVC 4 targeting .NET Framework 4.5 (just upgraded from 4.0) and I'm trying to integrate MailChimp.NET v3 inside it.
Thanks.
EDIT: Created a brand new MVC WebApplication .NET 4.5 project in VStudio 2015 and the same method compiles without errors. What should I check?
The problem was this line in the package.config file and more in general a number of lines in the same file still reporting targetFramework="net40"
:
<package id="AsyncCTP" version="0.3" targetFramework="net40" />
After retargeting the project to .NET framework 4.5 I should have called
Update-Package –reinstall <packageName>
for each package in the list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With