0
       this.Invoke((MethodInvoker)delegate
                { code;
                });

This results in exception as

Cannot access a disposed object. Object name: '...'.

How to handle this??

moribvndvs
  • 42,191
  • 11
  • 135
  • 149
progrrammer
  • 4,475
  • 2
  • 30
  • 38

1 Answers1

1

InnerException property of TargetInvocationException contains information you need to investigate (see Reflection MethodInfo.Invoke() catch exceptions from inside the method for sample).

In your case it looks like you are accessing some disposed objects (like closed streams) in your delegate. Not much to do with Invoke itself.

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179