Policy Injection and Generic Methods

Topics: Policy Injection Application Block
Aug 27, 2008 at 12:40 AM

I can't seem to find an answer to this question.  Perhaps I'm phrasing it incorrectly.

I'm trying to inject an exception handler into a class:



Tag("Inject Here")]
public class GenericMethodClass : MarshalByRefObject
    public void GenericThrowException<T>(T msg)
        throw new Exception(msg.ToString());

The handler is supposed to replace the Exception with an ApplicationException.  It doesn't do this.  It doesn't place any call handlers on the method at all.  If I remove the generic method parameter, it works as expected.  I'm would assume this is nothing new to any of you.

I'm guessing that policy injection doesn't work on generic methods, but my question is, is there any way around this?  Any "clean" way, at least?

Thanks for any help,


Aug 27, 2008 at 1:49 PM
Hi Brad,

Generic methods are unfortunately not supported by PIAB at this time. I've posted a change that seems to work as a temporary solution at http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=34190; you can apply the change to the source code or extract the RemotingInterception classes to a new assembly and use them as a custom injector.