如何使用城堡WCFFACACE并使用标准WCF配置文件设置?

如果我喜欢注册:

container.Register(
AllTypes.Pick()
    .FromAssemblyNamed("{ServicesAssembly}") // <-- service assembly here
    .If(type => type.Name.EndsWith("Service"))
    .WithService.FirstInterface()
    .Configure(configurer => configurer.LifeStyle.Transient)
    .Configure(configurer => configurer.Named(configurer.Implementation.Name))
    .Configure(configurer => configurer.ActAs(new DefaultServiceModel()))
);

我收到以下错误:

服务'{name}'具有零应用程序(非基础结构)端点。

如果我离开:

.Configure(configurer => configurer.ActAs(new DefaultServiceModel()))

似乎忽略了配置中的行为。

这里的正确用法是什么?

有帮助吗?

解决方案

好的,弄清楚了:)

我像这样注册:

container.Register(
AllTypes.Pick()
    .FromAssemblyNamed("{ServicesAssembly}") // <-- service assembly here
    .If(type => type.Name.EndsWith("Service"))
    .WithService.FirstInterface()
    .Configure(configurer => configurer.LifeStyle.Transient)
    .Configure(configurer => configurer.Named(configurer.Implementation.Name))
    .Configure(configurer => configurer.ActAs(new DefaultServiceModel().Hosted()))
);

托管() 是否在那里表明我正在托管服务;否则,WCF工厂似乎会尝试托管它们,从而导致港口冲突。

所以问题是 姓名 配置文件中的服务 拥有 成为实现的完整类型名称。如果没有收到错误,则说明了未定义的无端点的行。所以服务名称是 不是 与温莎指定的名称相同。

其他提示

您快到了。

你需要这个:

.ActAs(new DefaultClientModel(WcfEndpoint.FromConfiguration( <<key In Configuration>> )));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top