开发者

PostSharp - What am I doing Wrong?

I have a project Company.Business that I'm 开发者_如何学JAVAtrying 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜