我正在尝试使用WCFFacility在我的WinForms客户端上使用Castle Windsor注册我的WCF服务。 我可以使用
一次轻松完成这一项container.Register(Component.For<IMyService>()
.AsWcfClient(new DefaultClientModel
{
Endpoint = WcfEndpoint.BoundTo(new BasicHttpBinding { MaxReceivedMessageSize = 3000000 })
.At("http://localhost:51324/MyService.svc")
}));
但是我有数百人试图关注this answer
我使用了这段代码:
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)))
})));
不幸的是,在尝试解析我的服务时,这会给我以下错误: “类型MyNamespace.IMyService是抽象的。因此,不可能将其实例化为服务'IMyService'的实现。你忘了代理吗了吗?”
答案 0 :(得分:0)
修正了它!
我认为问题只是其他一些非服务类抛出导致注册失败的异常。
我没有收到添加WcfFacility的电话!
Container.Kernel.AddFacility<WcfFacility>();
据推测,注册失败导致Windsor将接口注册为实现类。