I use Castle Windsor in a couple of web apps just fine by putting the config data in web.config.
So when I decided to use it in a Windows Service I thought it would be a cinch. My app.config file looks like the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
</configSections>
...various other stuff...
<castle>
<components>
...component listings...
</components>
</castle>
</configuration>
I'm creating my container like this:
WindsorContainer windsorContainer = new WindsorContainer(new XmlInterpreter());
But crazily, when the app runs I get
Could not find section 'castle' in the configuration file associated with this domain.
at Castle.Core.Resource.ConfigResource..ctor(String sectionName)
at Castle.Core.Resource.ConfigResource..ctor()
at Castle.Windsor.Configuration.Interpreters.AbstractInterpreter..ctor()
at Castle.Windsor.Configuration.Interpreters.XmlInterpreter..ctor()
...application stack trace...
I'm a bit bamboozled. Anyone got any tips?
Cheers
David
I seem to recall something about app.config files and windows services. Since the application that is actually "running" your service is svchost.exe and that exe exists in %windir%\system32, that is where you config file needs to be. Try placing it there (%windir%\system32) and see what happens.