views:

67

answers:

1

Hello.

I'm using Castle Windsor with a configuration from my App.config file.

In the code I use :

IWindsorContainer container = new WindsorContainer(new XmlInterpreter());

to get the container.

But for some configurations of my application I don't want to use CastleWindsor (for some migration issues...) and therefore, I don't want to add any Castle section in my App.config.

And the problem is that if there is no castle config, then

IWindsorContainer container = new WindsorContainer(new XmlInterpreter());

throws an exception "Could not find section 'castle' in the configuration file associated with this domain."

So basically in my code I want to do something like:

if (IsCastleWindsorInitialized()) {/* do something */ } else {  /* do something else */ }

where 'IsCastleWindsorInitialized()' returns true when the App.config contains a castle section.

In order to implement that function I can certainly use the ConfigurationManager but I'm wondering if I can use Castle Windsor API to do that.

A: 

I would probe the app.config with a ConfigurationManager.GetSection("castle") (that is, if you use XML-only configuration)

Mauricio Scheffer
With ConfigurationManager it is ok. As written in my question, I wanted to know if that could be achieved without it, using CastleWindsor API only.
Thierry