i've class libraray which has two class files separately, one class file has a post sharp's aspect code as follows,
[Serializable]
public class TimingAspect : PostSharp.Aspects.OnMethodBoundaryAspect
{
[NonSerialized]
Stopwatch _StopWatch;
public override void OnEntry(PostSharp.Aspects.MethodExecutionArgs args)
{
_StopWatch = Stopwatch.StartNew();
base.OnEntry(args);
}
public override void OnExit(PostSharp.Aspects.MethodExecutionArgs args)
{
StackFrame frame = new StackTrace().GetFrame(1);
System.IO.StreamWriter file = new System.IO.StreamWriter("D:\\execution time.txt", true);
file.WriteLine(frame.GetMethod().DeclaringType.FullName + "-------" + frame.GetMethod().Name + "-----" + _StopWatch.ElapsedMilliseconds);
file.Close();
base.OnExit(args);
}
}
other class file has a assembly declaration as follows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;
[assembly: AspectLibrary.TimingAspect(AttributeTargetTypes = "Employee.*", AttributeTargetMembers = "Page_Load",AttributePriority=1)]
to add that aspect to all the namespaces of my project, and i've referenced this class library to my project, but attribute won't apply to the name spaces of my projects
What I have tried:
tried to add separate libraries for each class, and if i add that assembly declaration class inside the project ,it works, but i want it to be outside