TargetInvocationException in asynchronous web service call
I’ve seen so many solutions around to solve a TargetInvocationException raised by an asynchronous web service call in .NET and they are all but satisfactory. Some go so far to create a worker thread which is overkill and, above all, a clear sign of cargo culting.
The solution is very very simple. The exception is raised if a call fails due to a network problem, and you have accessed the Result properties of the completion event arguments. Simply check if the Error property is null before accessing the Result property (it’s this access which raises the exception).
by Marco Mastropaolo
"Thanks to you! :) "