Questions tagged [aggregateexception]

61 questions
57
votes
4 answers

How to fix "'System.AggregateException' occurred in mscorlib.dll"

I'm receiving an unhandled exception while debugging, and the program stops executing. The debugger doesn't show me the line so I don't know what to fix. An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll Additional…
Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305
26
votes
5 answers

Flattening of AggregateExceptions for Processing

I'm running into a few issues where I call flatten on an AggregateException, but inside there is still ANOTHER AggregateException! This obviously means that they are being propagated up the chain and being rolled into another AggregateException. …
JNYRanger
  • 6,829
  • 12
  • 53
  • 81
12
votes
1 answer

HttpClient - dealing with aggregate exceptions

Hi i am using HttpClient similar to this: public static Task AsyncStringRequest(string url, string contentType) { try { var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new…
gdp
  • 8,032
  • 10
  • 42
  • 63
8
votes
1 answer

C# InnerException in AggregateException

I have this code as below to capture the exceptions throw from tasks created by using TaskFactory and Task.Run. If I use the TaskFactory, I am able to check the Exception thrown from the previous task in the Continued task without having to use the…
Helic
  • 907
  • 1
  • 10
  • 25
7
votes
1 answer

TaskCanceledException in AggregateException does not contain stack trace

I am using the Task Parallel Library to run a task which - when cancelled - throws the OperationCanceledException, which is then caught using the AggregateException, as follows. The AggregateException contains a list of TaskCanceledExceptions,…
6
votes
1 answer

Wrapped AggregateException reports just first exception in ToString method

I get complete set of nested exceptions when I use ToString() method on AggregateException directly: public void GreenTest() { var ex = new AggregateException(new Exception("ex1"), new Exception("ex2")); ex.ToString() .Should() …
Buthrakaur
  • 1,821
  • 3
  • 23
  • 35
5
votes
3 answers

Confusion over AggregateException Handle method

ReSharper was giving me a CoVariantConversion warning so I decided to google this and see how to fix it. I came accross this snippet of code: // ReSharper disable CoVariantArrayConversion try { Task.WaitAll(taskList.ToArray()); } catch…
4
votes
1 answer

C# AggregateException, in what scenario would I have aggregated exceptions?

I am probably missing a very obvious fact, but I have a hard time understanding the need for AggregatedExceptions. I know since async/await we don't have to bother with AggregatedExceptions anymore (or at least are confronted with them less…
bas
  • 13,550
  • 20
  • 69
  • 146
4
votes
1 answer

AggregateException.Flatten() loses stack trace information. Is the lost info important or not?

The documentation on MSDN for the AggregateException.Flatten method says the following: "If any inner exceptions are themselves instances of AggregateException, this method will recursively flatten all of them. The inner exceptions returned in the…
Matthew Rodatus
  • 1,393
  • 9
  • 18
3
votes
0 answers

Why does catching AggregateException cause CA2000 dispose warning?

The code below causes a code analysis warning CA2000, claiming that I need to dispose of getRequest along all code paths before it goes out of scope. Tweaking the code slightly, for example removing the when from the catch, eliminates the…
Rob
  • 4,327
  • 6
  • 29
  • 55
3
votes
2 answers

AggregateException not caught by Task.Wait()

I'm trying to catch an NullReferenceException which is going to be thrown by Task.Factory.StartNew method. I think it should be caught by 'try' statement with task.Wait() method. I also referred to Why is this exception not caught?, but have no…
3
votes
0 answers

Unity3d, Parse.com throw exception, (System.AggregateException)

so i'm trying to use parse.com in my unity project, it was all working fine until i added a new column in my user database. It throw exception every time i tried to access my currentUser. In the error shown below, it mentioned that something goes…
libra
  • 673
  • 1
  • 10
  • 30
3
votes
1 answer

PLINQ exception

I am using PLINQ with code below: static void Main(string[] args) { var lt = new List() {1,2,3,4,5}; try { var nlt = lt.AsParallel().Select(Test).ToList(); } catch (AggregateException e) …
Sean
  • 981
  • 1
  • 9
  • 19
3
votes
2 answers

Many nested AggregateExceptions

Working with Entity Framework 7, I made a simple mistake with some linq (used Skip and forgot to include my OrderBy clause). The exception that was thrown by this included a number of nested aggregate exceptions. The code that generates (and…
Jon Egerton
  • 40,401
  • 11
  • 97
  • 129
3
votes
1 answer

Mark task exception as handled

How can I mark an exception thrown in a task as handled. The problem is when I call the Wait() method of a task, it will throw an AggregateException even when I have already handled the AggregateException a long time ago. The following code snippet…
1
2 3 4 5