Autofac.Extras.DynamicProxy2 v3.0.6 got an exception

I am using Autofac.Extras.DynamicProxy2 to implement my AOP policy.
I updated Autofac.Extras.DynamicProxy2 to 3.0, I got an exception:

Component Activator = LookupService (ReflectionActivator), Services = [WordBook.Protocols.Logic.ILookupService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope cannot use interface hijacking because it provides services that are not are public interfaces. Check your component registration to ensure that you do not include interception and registration as an internal / private interface type.

This is my original code:

ContainerBuilder builder = new ContainerBuilder();

builder.RegisterType<ExceptionInterceptor>();

builder.RegisterAssemblyTypes(Assembly.Load("WordBookLogics")).AsImplementedInterfaces().EnableInterfaceInterceptors();

var container = builder.Build();

DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

      

It works on Autofac.Extras.DynamicProxy2 v3.0.5.

Do I need to adjust something when updating?

+3


source to share


1 answer


I think I found the problem.

In Autofac.Extras.DynamicProxy2 v3.0.5 line 300 from RegistrationExtensions.cs has the IsVisible condition.

But the IsVisible condition has been replaced with Assembly.IsInternalToDynamicProxy () in Autofac.Extras.DynamicProxy2 v3.0.6.

The IsVisible property of my public interface is true, but the result I call Assembly.IsInternalToDynamicProxy () on my public interface is false.



So my public interface is visible, but it is not in the middle for a dynamic proxy.

This is the reason why my interception was not working and got an exception in Autofac.Extras.DynamicProxy2 v3.0.6.

I'm just waiting for the owner of Autofac.Extras.DynamicProxy2 to fix it.

+1


source







All Articles