Async Code and Progress Issue
-
15 апреля 2012 г. 20:36
Edited to point to the error
Stepping through the code right after my Task execution using async
I got this error :
"Exception has been thrown by the target of an invocation" seems referring to some innerExceptions regarding "null" and use "new" for instances ...
--
That was a "Null Exception" hidden in debugging
The problem is solved with the help of Stephen
- Изменено MHM-Mz 15 апреля 2012 г. 20:56
- Изменено MHM-Mz 15 апреля 2012 г. 21:09
- Изменено MHM-Mz 16 апреля 2012 г. 6:13
- Изменено MHM-Mz 16 апреля 2012 г. 6:14
- Изменено MHM-Mz 16 апреля 2012 г. 6:15
- Изменено MHM-Mz 16 апреля 2012 г. 10:01
- Изменено MHM-Mz 16 апреля 2012 г. 15:34
- Изменено MHM-Mz 17 апреля 2012 г. 7:43
- Изменено MHM-Mz 17 апреля 2012 г. 18:35
- Изменено MHM-Mz 17 апреля 2012 г. 18:38 The question path changed
Все ответы
-
17 апреля 2012 г. 15:04Модератор
I suggest turning on first-chance exceptions in Visual Studio and let the debugger break in when the exception occurs http://msdn.microsoft.com/en-us/library/d14azbfh.aspx. It sounds like you're trying to dereference a null variable somewhere.- Предложено в качестве ответа Stephen Toub - MSFTMicrosoft Employee, Moderator 17 апреля 2012 г. 15:26
- Изменено Stephen Toub - MSFTMicrosoft Employee, Moderator 17 апреля 2012 г. 17:24 Fixed link formatting
- Помечено в качестве ответа MHM-Mz 17 апреля 2012 г. 18:30
-
17 апреля 2012 г. 16:18
Thanks Stephen, answering
Yes, I think I should debug inside the task,
Is the structure I built correct ?
The Error I got is :
"Exception has been thrown by the target of an invocation."
The Error point to this line :Application.Run(new Main());
The dialog shows InneException of "NullReferenceException"
and the VS doesn't help me to find which pieces of the code has thrown this error,
before adding the Progress Reporting functionality it was working as expected
stepping through the code I encounter an error right after the Task
Task<MyCollection> theCollectingProcess = Task.Factory.StartNew(() => { MyCollection wResult = new MyCollection(); wResult = DoCollect(docProcess, progress,cts); return wResult; });If I be sure my code structure and lambda which I'm not professional in it yet is correct so I'll focus on the function itself and how it will report the Progress.
- Изменено MHM-Mz 17 апреля 2012 г. 16:21
-
17 апреля 2012 г. 16:48Модератор
You said that "VS doesn't help me to find which pieces of the code has thrown this error"... is that true even after following my suggestion of enabling first-chance exceptions so that VS breaks in when the exception occurs initially?
-
17 апреля 2012 г. 17:16
Unfortunately your provided link didn't work for me at that time,
seemed it had an extra parenthesis on it, now I'm going to read the article and debug it the right way,
thanks,
will inform you the result

