castle wcf facility set serviceBehavior configuration name in code

524 views Asked by At

I have several services which I want to register dynamically instead of having an entry for each in the app.config, smiliar to the following example.

<service name="MyService.Service" behaviorConfiguration="serviceBehavior">
<endpoint name="tcpEndpoint" 
      binding="netTcpBinding" 
      bindingConfiguration="netTcp" 
     address="net.tcp://localhost:4321/MyService" 
    contract="MyContract.IContract" />
</service>

I know how I can create the endpoints dynamically, but I dont know how I can define the behaviorConfiguration on the DefaultServiceModel.

Is there a way to reuse my service behavior from the app.config?

1

There are 1 answers

2
Matt Whetton On

One thing that you can do is add the behaviors as you define the endpoint, something like this:

WcfEndpoint.BoundTo(new NetTcpBinding("netTcp")).At(url).AddExtensions(new YouBehavior())