PolicyInjection When Use private Method

Nov 20, 2014 at 9:03 AM
Edited Nov 20, 2014 at 9:04 AM
When I use PolicyInjection to do something about crosscut,I found that when I set the method as private, The CrossCut can not be gone into.

Code is here:
public class Demo : MarshalByRefObject
    public void Test1(string sql, string param)

    private void DoSomething()
Nov 20, 2014 at 8:33 PM
Unfortunately, you won't be able to intercept private "self-call" methods. This is a limitation of the interception mechanisms. The best you can do would be to change to use Unity for interception along with a VirtualMethodInterceptor. But even in that case you will not be able to have private methods intercepted because VirtualMethodInterceptor requires intercepted methods be virtual (and private methods cannot be virtual).

This question is similar to yours and provides some more details: http://entlib.codeplex.com/discussions/535739

Randy Levy
Enterprise Library support engineer
Support How-to