castle wcf设施集代码中的serviceBehavior配置名称
我想动态注册几个服务,而不是在app.config中为每个服务创建一个条目,参见下面的示例castle wcf设施集代码中的serviceBehavior配置名称,wcf,castle-windsor,wcffacility,Wcf,Castle Windsor,Wcffacility,我想动态注册几个服务,而不是在app.config中为每个服务创建一个条目,参见下面的示例 <service name="MyService.Service" behaviorConfiguration="serviceBehavior"> <endpoint name="tcpEndpoint" binding="netTcpBinding" bindingConfiguration="netTcp" address="net.tcp:
<service name="MyService.Service" behaviorConfiguration="serviceBehavior">
<endpoint name="tcpEndpoint"
binding="netTcpBinding"
bindingConfiguration="netTcp"
address="net.tcp://localhost:4321/MyService"
contract="MyContract.IContract" />
</service>
我知道如何动态创建端点,但不知道如何在DefaultServiceModel上定义behaviorConfiguration
有没有办法重用app.config中的“我的服务”行为?您可以做的一件事是在定义端点时添加行为,如下所示:
WcfEndpoint.BoundTo(new nettcppbinding(“netTcp”)).At(url).AddExtensions(new YouBehavior())如何动态创建端点?您正在使用ServiceHostFactory吗?类似于:WcfEndpoint.BoundTo(new nettcppbinding(“netTcp”)).At(url);使用netTcp,我定义了绑定配置,我可以在app.config中修改它。我也希望对serviceBehavior执行同样的操作。如何获得我在app.config中定义的行为?我认为没有任何方法可以直接从配置文件加载它,但您可以在代码中复制每个行为