.netcastle-windsorcastle-dynamicproxy

Why am I getting Interceptor attempted to ‘Proceed’ for a method without a target error?


In my case I have main project and test project. I was getting proper results on the test project where I have only one Installer class and register everything in one place. In my main project I had several installers (one for service, one for interceptors, one for common libraries, one for data persistence). For the main project I was getting the error specified:

This is a DynamicProxy2 error: the inter­cep­tor attempted to ‘Pro­ceed’ for a method without a target, for example, an interface method or an abstract method

I was struggling to find out what was wrong. I plugged into my constructor that accepts interface of a data persistence layer and saw that it only receives a proxy object.


Solution

  • Why this was happening is specified here: http://kozmic.net/2009/03/20/castle-dynamic-proxy-tutorial-part-viii-interface-proxy-without-target/

    Krzysztof explains that you Castle can resolve even an interface, and Windsor will create a class for you. However if you want to use an interceptor and call a invocation.Proceed() method you need to specify what happens inside that method (for ex. using lambda expression)

    Solution: In my case solution was to put all installers into one, except of the interceptor installer. That one could stay alone, and eveything was fine.