简体   繁体   中英

Autofac using DynamicProxy2 Interception with WcfIntegration

I'm struggling to wire up a service interface using WcfIntegration with an IInterceptor.

There are examples for each in the autofac documentation but nothing that combines the two.

Here is the documentation for the WcfIntegration and look here for the DynamicProxy2 documentation.

Has anyone successfully wired up an interceptor with WcfIntegration using Autofac?

Example code I'd have expected to work:

            builder.Register(c => new CacheInterceptor())
            .Named<IInterceptor>("cache-calls");

        builder
            .RegisterType<ChannelFactory<IEnquiryService>>()
            .AsSelf()
            .WithParameter(new NamedParameter("endpointConfigurationName", "EnquiryService"))
            .SingleInstance();

        builder
            .Register(c => c.Resolve<ChannelFactory<IEnquiryService>>().CreateChannel())
            .As<IEnquiryService>()
            .EnableInterfaceInterceptors()
            .InterceptedBy("cache-calls");

EDIT:

Seems like a bug has been logged on autofac site. Any work arounds for this?

As this has been raised as a bug on autofac bugtracker, If no one can see a workaround, I'll mark this as the answer. They have uploaded a console app reproducing the exact scenario.

http://code.google.com/p/autofac/issues/detail?id=361&q=dynamicproxy2

EDIT: This has now been fixed in the latest version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM