views:

51

answers:

1

Hello,

I have a project Company.Business that I'm trying to target with PostSharp to wrap my business layer. In the project Company.AOP, I have a method boundary aspect to use EL logging application block as such:

[Serializable]
public class MethodExcecutionAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionEventArgs eventArgs)
    {
        base.OnEntry(eventArgs);

        //Log message
    }

    public override void OnException(MethodExecutionEventArgs eventArgs)
    {
        base.OnException(eventArgs);

        //Log message
    }

    public override void OnExit(MethodExecutionEventArgs eventArgs)
    {
        base.OnExit(eventArgs);

       //Log message
    }
}

Simple enough; it simply logs the point in time. I try to target my entire business layer via:

[assembly: MethodExcecution(AttributeTargetTypes = "*", 
    AttributeTargetAssemblies = "Company.Business",
    AttributeTargetTypeAttributes = MulticastAttributes.Public,
    AttributeTargetMemberAttributes = MulticastAttributes.Public)]

But after compile, I inspect the DLL and it does not wrap the code as in the examples on the web site. What is wrong with this approach?

I do have it installed, and I verified it is running; it is generating output during compile time, with zero errors.

Thanks.

A: 

There's a bug in the current release: if you specify AttributeTargetAssemblies, it will look only at assembly references, not the current project.

So if you want to add aspects to the current project, remove AttributeTargetAssemblies.

Gael Fraiteur
So am I required then to have the aspects in the same project that I'm targeting, or what is the way that Company.AOP aspects in that DLL target the Company.Business components? I'm confused. Thanks.
Brian