开发者

Proper error messages on registering wcf client components in Castle Windsor

I'm trying to get an error message when I try to register a component in Castle Windsor that points to WCF Service that has errors in the configuration. For registering the component I'm using:

container.Register(Component.For<MembershipService>().ImplementedBy<MembershipServiceClient>.LifeStyle.Transient);

The configuration file has the following 开发者_StackOverflowtwo entries (bindings points to a non existing file):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings configSource="Configs\local\nonexistingbindingfile.xml"/>
    <client configSource="Configs\local\system.serviceModel.client.xml"/>
  </system.serviceModel>
</configuration>

What happens is that Castle won't fail registering my component but it won't resolve MembershipService for any dependency of other components, it would set the property as null, but at this point I don't have any error logs that points to the file with the problem and troubleshooting becomes very hard.

Thanks.


If a valid instance is essential then I believe it should be done via Constructor injection rather than Property injection. This way Castle will throw if it can't resolve.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜