Do Aspect Oriented Programming using PostSharp (IL Weaving)

edited March 2017
I was try to run following code in LINQPad as C# Program expecting following output:
pre invocation
This is func
post invocation

I'm able to do it in visual studio but not in LINQPad, what could be the reason ?
void Main() { Test t = new Test(); t.func(); } [Serializable] public class CacheAspect : MethodInterceptionAspect { public override void OnInvoke(MethodInterceptionArgs args) { Console.WriteLine("pre invocation"); base.OnInvoke(args); Console.WriteLine("post invocation"); } } public class Test { [CacheAspect()] public void func() { Console.WriteLine("This is func"); } }


  • It looks like PostSharp relies on some MSBuild magic to invoke an executable to instrument the target assembly after compilation. LINQPad doesn't use MSBuild - it just compiles C# code with references, which means the target assembly won't get specially modified.
  • Thanks Sir, feels great to get response from you.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!