Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

Also, see here: Manually Loading the Factory Extension into the Ninject Kernel

Under some circumstances it may be necessary to manually load the extension. The solution in my case was to add the following code during kernel construction:

if (!kernel.HasModule("Ninject.Extensions.Factory.FuncModule"))
{
    kernel.Load(new FuncModule());
}

If you have this problem by Update method so change it like this :

 var myObj = _dbContext.Set<T>().Find(entity.Id);
 _dbContext.Entry(myObj).CurrentValues.SetValues(entity);
_dbContext.SaveChanges();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top