PIAB: Attributes Don't Work on Interfaces

Topics: Policy Injection Application Block
Apr 17, 2007 at 4:05 PM
Edited Apr 17, 2007 at 4:07 PM
I noticed that when I add the attributes to a concrete class like below caching works fine:


public class NewsService : INewsService
{
    [CachingCallHandler(0, 0, 30)]
    public IList GetRecentNews()
    {
	// ...
    }
}

However, when I add the attributes to the interface and not the concrete class caching does not work:

public interface INewsService
{
    [CachingCallHandler(0, 0, 30)]
    IList GetRecentNews();
}

However, if I add a TagMatchingRule on the Interface that specifies CachingCallHandler via configuration caching works fine:

public interface INewsService
{
    [Tag("Caching")]
    IList GetRecentNews();
}

Can someone explain this inconsistency? Is this by design or an oversight?

I would prefer to just use the [CachingCallHandler(0, 0, 30)] Attribute on the interface.

Regards,

Dave

_____________________

David Hayden
Microsoft MVP C#
Apr 17, 2007 at 9:25 PM
It should work. I'll do some digging and get back to you, but it may take a couple of days.
Apr 18, 2007 at 9:32 PM
I've confirmed the bug exists. I should have a source patch put together in the next couple of days.
Apr 18, 2007 at 11:25 PM
Thanks, Chris.

The TagAttributeRule is a fine workaround so no rush.

Regards,

Dave

_____________________

David Hayden
Microsoft MVP C#
Apr 23, 2007 at 9:25 PM

ctavares wrote:
I've confirmed the bug exists. I should have a source patch put together in the next couple of days.



I think I have run into this same bug. I am trying to use the ValidationCallHandler on an interface and I can't get the handler to fire. Where do I download this patch?