[Mono-list] Using Exceptions with external Plugins

Arild Fines arild.fines@broadpark.no
Tue, 29 Jun 2004 01:54:04 +0200


mono-list-admin@lists.ximian.com wrote:
> Hi!
>
> I'm loading many plugins (assemblies, dll) from my App.exe, however
> sometimes a plugin can throw an exception, how can I catch it?, I can
> only catch the System.Reflection.TargetInvocationException cause I'm
> using Reflection/Invoke techniques.. but I can't 'catch' 'internal
> Exceptions' of these plugins.
>
> For example, a Plugin.dll can throw a
> CookComputing.XmlRpc.XmlRpcFaultException and it doesn't works, however
> System.Reflection.TargetInvocationException seems to catch it, but just
> the Invoke Exception.
>
> Any ideas?
> Pablo

The docs on TargetInvocationException has this:

"When created, the TargetInvocationException is passed a reference to the
exception thrown by the method invoked through reflection. The
InnerException property holds the underlying exception."

So tex.InnerException should give you what you need.

--
Arild

AnkhSVN: http://ankhsvn.tigris.org
Blog: http://ankhsvn.com/blog
IRC: irc://irc.freenode.net/ankhsvn

"Weaseling out of things is good. It's what separates us from the other
animals....except weasels." -- Homer Simpson