Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top