Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
System.Reflection
MethodBase Class
MethodBase Methods
Invoke Method
Collapse All/Expand All Collapse All
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
.NET Framework Class Library
MethodBase..::.Invoke Method

Invokes the method or constructor reflected by this MethodInfo instance.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  NameDescription
Public methodInvoke(Object, array<Object>[]()[])Invokes the method or constructor represented by the current instance, using the specified parameters.
Public methodInvoke(Object, BindingFlags, Binder, array<Object>[]()[], CultureInfo)When overridden in a derived class, invokes the reflected method or constructor with the given parameters.
Top
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Undesirable behavior: Captures exceptions, rethrows them as System.Reflection.TargetInvocationExcept      Ken Birman   |   Edit   |   Show History
The .Invoke methods (including DynamicInvoke) have an undesirable behavior: when running directly in the CLR (as opposed to within Visual Studio), if an application throws an exception in the context of a .Invoke, the .Invoke catches the exception (no matter what kind) and then rethrows it as the inner exception of a System.Reflection.TargetInvocationException, which will be unhandled and hence causes the application to terminate. If you attach a debugger at this point, the stack will have been unwound, hence you can obtain the line number at which your exception occured, and also the cause, but won't be able interrogate local variables or see the arguments to the methods that were called. To avoid this, cast to dynamic, as in: ((dynamic)Foo).Invoke(args)
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker