简体   繁体   English

使用DynamicProxy2拦截与WcfIntegration的Autofac

[英]Autofac using DynamicProxy2 Interception with WcfIntegration

I'm struggling to wire up a service interface using WcfIntegration with an IInterceptor. 我正在努力使用WcfIntegration与IInterceptor连接服务接口。

There are examples for each in the autofac documentation but nothing that combines the two. autofac文档中各有一些示例,但两者都没有结合。

Here is the documentation for the WcfIntegration and look here for the DynamicProxy2 documentation. 下面是文档WcfIntegration看这里的DynamicProxy2文档。

Has anyone successfully wired up an interceptor with WcfIntegration using Autofac? 有没有人使用Autofac成功连接了WcfIntegration的拦截器?

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. 好像在autofac网站上记录了一个错误 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. 由于这已被提出作为autofac bugtracker的错误,如果没有人能看到解决方法,我会将此标记为答案。 They have uploaded a console app reproducing the exact scenario. 他们上传了一个控制台应用程序来重现确切的场景

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

EDIT: This has now been fixed in the latest version 编辑:现在已在最新版本中修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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