Search code examples
postsharp

PostSharp aspect not working when implement into assembly and calling that method


I have two three projects

1. framework 2. Repository 3. MVC Project

In framework project i implemented aspect

namespace FrameworkHelper.TestAspect
{
    [Serializable]
    [MulticastAttributeUsage(MulticastTargets.Method)]
        public class CacheAspect : OnMethodBoundaryAspect
        {
            // This field will be set by CompileTimeInitialize and serialized at build time, 
            // then deserialized at runtime.
        public string methodName;

            // Method executed at build time.
            public override void CompileTimeInitialize(MethodBase method, AspectInfo aspectInfo)
            {
                this.methodName = method.DeclaringType.FullName + "." + method.Name;
            }



            // This method is executed before the execution of target methods of this aspect.
            public override void OnEntry(MethodExecutionArgs args)
            {

            }

            // This method is executed upon successful completion of target methods of this aspect.
            public override void OnSuccess(MethodExecutionArgs args)
            {

            }
        }
}


And aspect implemented into repository project 

[TestAspect]
public List<string> TestMethod()
{


}

, When we calling method TestMethod() from MVC project , aspect not working , what's wrong on this code.

Its working fine when we use with one assembly.


Solution

  • Sorry Daniel, Its working fine with latest version of postsharp , right now using Postsharp of 3.1.50.9

    Before i used 3.1.48 , May be that's problem with old version.

    Thanks