// aspect code: [AttributeUsage(AttributeTargets.Class)] public class SecurityAspectAttribute: { public SecurityAspectAttribute() { } public override void PreProcess(System.Runtime.Remoting.Messaging.IMessage msg) { System.Windows.Forms.MessageBox.Show("pre"); } public override void PostProcess(System.Runtime.Remoting.Messaging.IMessage msg) { System.Windows.Forms.MessageBox.Show("post"); } } // client code: [SecurityAspect] public class Class1: { public Class1() { } public void test() { System.Windows.Forms.MessageBox.Show("test"); } }