C# 谷歌内容服务执行时等待错误

C# 谷歌内容服务执行时等待错误,c#,asynchronous,gdata,C#,Asynchronous,Gdata,我正试图通过以下代码将我们的产品列表推送到谷歌: string path = HttpContext.Current.Server.MapPath("/keya.p12"); String serviceAccountEmail = "#######@developer.gserviceaccount.com"; var certificate = new X509Certificate2(@path, "notasecret", X509KeyS

我正试图通过以下代码将我们的产品列表推送到谷歌:

string path = HttpContext.Current.Server.MapPath("/keya.p12");
            String serviceAccountEmail = "#######@developer.gserviceaccount.com";
            var certificate = new X509Certificate2(@path, "notasecret", X509KeyStorageFlags.Exportable);
            var init = new ServiceAccountCredential.Initializer(serviceAccountEmail)
            {
                Scopes = new[] { Google.Apis.Content.v2.ContentService.Scope.Content }
            }.FromCertificate(certificate);

            ServiceAccountCredential credential = new ServiceAccountCredential(init);

            // Create the service.
            service = new Google.Apis.Content.v2.ContentService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "MY APP",
            });
service.Products.Insert(p, ######).Execute();
但是,无论我做什么,我都会在那一行中遇到这个错误:

方法 System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1[System.Net.Http.HttpResponseMessage]。等待未安全完成:
类型参数“Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter[System.Net.Http.HttpResponseMessage]” 违反类型参数“tawater”的约束


我正在WebAPI控制器中运行此代码。我还尝试了一个通用处理程序,并得到了相同的错误。我找到的一个参考资料说要更新我的Microsoft.Bcl包,我没有做任何更改。

我建议你更新整个Google.api.Calendar.v3库。 在您的NuGet控制台中,执行
安装包Google.api.Calendar.v3
,以获取包及其依赖项的最新版本

在向服务帐户进行日历呼叫时,我遇到了相同的错误。我使用的是图书馆的1.8.1.820版。更新为我解决了这个问题