我正在使用谷歌api v3,我嘗試使用這個例子,第一個說:檢索我的上傳。在這個例子中,他們使用Run和Wait。我想以這種方式嘗試。 這是例子的頂部:爲什麼我在新類中出現錯誤:不包含「運行」的定義?
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace Google.Apis.YouTube.Samples
{
/// <summary>
/// YouTube Data API v3 sample: retrieve my uploads.
/// Relies on the Google APIs Client Library for .NET, v1.7.0 or higher.
/// See https://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
/// </summary>
internal class MyUploads
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("YouTube Data API: My Uploads");
Console.WriteLine("============================");
try
{
new MyUploads().Run().Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("Error: " + e.Message);
}
}
這是我的課我做了什麼:
using System.Text;
using System.Threading.Tasks;
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace Youtube
{
class Youtube_Retrieve_Uploads
{
public Youtube_Retrieve_Uploads()
{
try
{
new Youtube_Retrieve_Uploads().Run().Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("Error: " + e.Message);
}
}
}
}
}
我得到的錯誤是:
錯誤1「Youtube.Youtube_Retrieve_Uploads '不包含'運行'的定義,並且沒有找到接受'Youtube.Youtube_Retrieve_Uploads'類型第一個參數的擴展方法'運行'(缺少使用指令或程序集引用?)
我不確定你在這裏試圖做什麼,因爲它說,'Youtube_Retrieve_Uploads'中沒有'Run'方法,看起來你期望構造函數返回某種類型的任務?即使你可以得到這個編譯,它會拋出一個堆棧溢出異常... –
看起來像代碼示例丟失運行方法...如果它確實是完整的[MCVE]比我看不出爲什麼你期望此代碼工作 - 請提供你的推理爲什麼你顯示的分類應該有'運行'方法。 –