Splitting WCF ServiceHost configurations into separate files?

J

jonesst2608

Hi,

I have several ServiceHost instances each implemented in its own DLL.
The services are being self-hosted by a forms application.

I'd like to split the ServiceHost configuration parameters that are
all currently held in App.config into separate files so allowing the
service configurations to be managed more easily.

The only way I can see to do this is to subclass ServiceHost and
implement my own XML based configuration sub-system but this seems
insane.

Does anyone know an easy way to do this?

Thanks, Steve.
 
S

sloan

You talking about something like this??

<?xml version = "1.0" encoding = "utf-8" ?>
<configuration>

<configSections>
<section name="dataConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>

<appSettings file="CustomAppSettings.config" >
</appSettings>


<connectionStrings configSource="ExternalConnectionStrings.config" />

<dataConfiguration defaultDatabase="MainDatabaseConnectionString"/>

<system.serviceModel>


<behaviors configSource="WCFBehaviors.config">
</behaviors>


<bindings configSource="WCFBindings.config">
</bindings>

<client configSource="WCFClient.config" >
</client>

<services configSource="WCFServices.config" >
</services>


</system.serviceModel>




<system.diagnostics configSource="SystemDiagnostics.config">
</system.diagnostics>


</configuration>


Google
"bindings configSource" and "system.serviceModel"
and I think you'll find the same URL I did about it.
 
J

jonesst2608

Hi,

That's a step in the right direction.

Ideally I want to keep the <service>, <serviceBehaviors> ... etc in a
service specific
configuration file, eg ServiceA.dll is entirely configured by
ServiceA.config.

I'm wondering if my self-hosting parent application could
programmatically
change configSource="ServiceX.config" before instantiating the
specific
service X.

I'll have to investigate.

Thanks.
 
S

sloan

Well, a config file is just a fancy xml document, so that's possible.

I went the other route I think.

When I have several different projects, I end up having the app.config file
of the Host(er) as seen below.
Then I've written some el-crappo code to merge different app's into the
single WCFService.config file.

If you figure out anything, post a follow up (probably in a new thread, or
it'll get lost).

...

As a side note, you may want to look at the

msdn.microsoft.com/stocktrader/

Greg has put together a Configuration framework piece. Its still in its
infancy, but is going to be great for managing multiple machine wcf/config
settings.

channel9/wiki site has some videos (with Greg explaining) as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top