C#System.AggregateException已被抛出

时间:2018-03-20 21:41:37

标签: c# visual-studio console-application

我目前正在开发一个控制台应用程序,它使用Last10kAPI从他们提供的各种文档中检索财务数据,但每当我构建应用程序时,它编译并打开终端我得到一个奇怪的错误,说“System.AggregateException已经抛出。发生了一个或多个错误。(无法对空引用执行运行时绑定)“为了简单起见,我在下面的Program.cs中编写了一些代码。将其添加到stackoverflow时,格式有点偏,所以只需假设适当的缩进。任何帮助,将不胜感激。提前致谢!

class Program
{

    static void Main(string[] args)
    {
        RunAsync().Wait();
        Console.WriteLine("Financial Data from Ratios, Balance Sheet, Cash Flow, and Income Statement");
    }


    static private async Task RunAsync()
    {
        //Grab our ticker List;
        List<string> tickers = new List<string>();
        tickers = await GetTickers();

        //Grab ratios for all companies in ticker list and store the results in a list of Ratios
        List<Ratios> ratiosfortickers = new List<Ratios>();
        foreach (string ticker in tickers)
        {
            Ratios tempRatio = new Ratios();
            tempRatio = await GetRatio(ticker);
            ratiosfortickers.Add(tempRatio);
        }

        //Grab all balance sheet
        List<BalanceSheets> balancesheetfortickers = new List<BalanceSheets>();
        foreach (string ticker in tickers)
        {

            BalanceSheets tempBalanceSheets = new BalanceSheets();
            tempBalanceSheets = await GetBalanceSheet(ticker);
            //balancesheetsfortickers.Add(tempBalanceSheets);

        }

        //Grab all Cash Flow
        List<CashFlows> cashflowsfortickers = new List<CashFlows>();
        foreach (string ticker in tickers)
        {
            CashFlows tempCashFlow = new CashFlows();
            tempCashFlow = await GetCashFlows(ticker);
            cashflowsfortickers.Add(tempCashFlow);
        }



        //Grab all Income Statement
        List<Income> incomefortickers = new List<Income>();
        foreach (string ticker in tickers)
        {
            Income tempIncome = new Income();
            tempIncome = await GetIncome(ticker);
            incomefortickers.Add(tempIncome);
        }
    }

}


  }   

0 个答案:

没有答案