'System.AggregateException' occurred in ms

2019-06-14 20:29发布

问题:

Consider the following code:

using Microsoft.AspNet.SignalR.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Stock
    {
        public string Symbol { get; set; }
        public decimal Price { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var hubConnection = new HubConnection("http://www.contoso.com/");
            IHubProxy stockTickerHubProxy = hubConnection.CreateHubProxy("StockTickerHub");
            stockTickerHubProxy.On<Stock>("UpdateStockPrice", stock => Console.WriteLine("Stock update for {0} new price {1}", stock.Symbol, stock.Price));
            hubConnection.Start().Wait();
            Console.ReadLine();
        }
    }
}

When run, I am getting "An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll". I tried the accepted answer from this question, but I had no idea how to actually fill the form there. How can I get details on what went wrong in this code sample? Here's what the "Exceptions" window looks like for me:

回答1:

As Patrick Eckebrecht noted in his comment to this question, it was enough to click "View Detail" to find the reason for the exception: