autofac / Autofac.Extras.DynamicProxy

Interceptor and decorator support for Autofac IoC via Castle DynamicProxy
MIT License
106 stars 33 forks source link

AutoFac 5.0 not supported #31

Closed connellsharp closed 4 years ago

connellsharp commented 4 years ago

Now that Aufofac 5.0 has been released, the integration with Autofac.Extras.DynamicProxy throws an exception.

Here is a test repo demonstrating the error.

It looks to be because of this commit and that ComponentRegistration.RaiseActivating is now being called twice. This causes an error when calling the second ProxyGenerator.CreateInterfaceProxyWithTarget:

Castle.DynamicProxy.ProxyGenerationException: This is a DynamicProxy2 error: Target type for the proxy implements Castle.DynamicProxy.IProxyTargetAccessor which is a DynamicProxy infrastructure interface and you should never implement it yourself. Are you trying to proxy an existing proxy?

tillig commented 4 years ago

Yup, that's mentioned in the release notes

Still TODO

Now that Autofac 5.0 is out, there is still a lot to do. We'll be working on these things as fast as we can:

  • Updating integration packages we support so they ensure compatibility with Autofac 5.
  • Updating the documentation to reflect the above changes.

Some of this is sitting in branches ready to go, other things need to be done now that we have this core package out there.

If your favorite integration isn't ready yet, we're doing our best. Rather than filing "When will this be ready?" issues, consider pull requests with the required updates.

forever84721 commented 3 years ago

Autofac 5.0.0 Autofac.Extras.DynamicProxy 4.5.0 Not workig

Autofac 6.0.0 Autofac.Extras.DynamicProxy 6.0.0 Working

If I have to use Autofac 5.0.0, How can I solve this problem? I can't find a related discussion, thank you.

tillig commented 3 years ago

This is a different issue, but: you can't. Any time you see a major version upgrade (Autofac.Extras.DynamicProxy v5.0.0 to v6.0.0) it indicates a breaking change. In this case, the breaking change is the forced upgrade to Autofac core. It's always wise to read the release notes before taking any update. In this case, the release notes tell you about the forced upgrade. If you can't upgrade core Autofac, you can't take this upgrade either.