MethodInfo.Invoke on proxy does not pass exceptions

5 views
Skip to first unread message

Allan Ritchie

unread,
Nov 12, 2009, 10:07:29 AM11/12/09
to Castle Project Users
So let's assume I have a proxy class instance ready

Castle.Proxy.IMyClass (reflected proxy type)

I have used reflection to get a particular method from it. In the
implementation of the method I have:
public void MyMethod(int arg1) {
throw new Exception("Boo");
}

Now, I call:
reflectedMethod.Invoke(instanceOfProxy, args); // this calls method
and all interceptors correctly

The exception gets gobbled up by invoke call. If I remove the
interceptors, thereby removing the need for the proxy class, the
exception is thrown as normal.

Basically, I want those exceptions to thrown like normal. Anybody
have any suggestions as to how I go about that?



Krzysztof Koźmic

unread,
Nov 12, 2009, 4:46:39 PM11/12/09
to castle-pro...@googlegroups.com
can you create a test case?
> --
>
> You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
> To post to this group, send email to castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=.
>
>
>

Allan Ritchie

unread,
Nov 23, 2009, 1:53:57 PM11/23/09
to Castle Project Users
Hi Krzysztof

Sorry for the delayed reply. There is no bug. I was reflecting the
method off the implementation that had a service. Once I started
reflecting the method out of the service, all started working like it
should.

On Nov 12, 4:46 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages