[英]How do I use Castle Windsor to register multiple WCF services at client end
I am trying to register my WCF services with Castle Windsor on my WinForms client using the WCFFacility. 我正在尝试使用WCFFacility在WinForms客户端上向Castle Windsor注册我的WCF服务。 I can easily do this one at a time using
我可以一次轻松地使用
container.Register(Component.For<IMyService>()
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = 3000000 })
.At("http://localhost:51324/MyService.svc")
}));
However I have hundreds so tried to follow this answer 但是我有数百个尝试遵循此答案
I used this code: 我使用以下代码:
container.Register(
Types
.FromAssemblyContaining<IMyService>()
.Pick()
.If(s => s.Name.EndsWith("Service"))
.Configure(
configurer => configurer.Named(configurer.Implementation.Name)
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = 3000000 })
.At(string.Format("http://localhost:{0}/{1}.svc", Port, configurer.Name.Substring(1)))
})));
Unfortunately this gives me the following error when trying to resolve my service: "Type MyNamespace.IMyService is abstract. As such, it is not possible to instantiate it as implementation of service 'IMyService'. Did you forget to proxy it?" 不幸的是,这在尝试解析服务时给了我以下错误:“类型MyNamespace.IMyService是抽象的。因此,无法将其实例化为服务'IMyService'的实现。您是否忘了代理它?”
Fixed it! 修复!
I think that the problem was simply that some other non-service classes were throwing exceptions causing the registration to fail. I hadn't included the call to add the WcfFacility! 我认为问题仅在于其他一些非服务类抛出异常导致注册失败。
我没有包括添加WcfFacility的电话!
Container.Kernel.AddFacility<WcfFacility>();
Presumably the registration just failed resulting in Windsor registering the interface as the implementing class. 大概注册失败,导致Windsor将接口注册为实现类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.