Started playing with Castle Windsor Container

And all I have done so far is spill blood, trying to add Windsor to a working DCOM service.

So I’m going to try go back to square one, get the basic examples working, and progress from there…

Update: So I was trying

Container = new WindsorContainer(new XmlInterpreter());

or

Container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));

but always got:

System.Configuration.ConfigurationException was unhandled
Message=”Could not find section ‘castle’ in the configuration file associated with this domain.”
Source=”Castle.Core”
BareMessage=”Could not find section ‘castle’ in the configuration file associated with this domain.”
Line=0
StackTrace:
at Castle.Core.Resource.ConfigResource..ctor(String sectionName)
at METScomms.MainProgram.Main() in C:\dev\METSsharpe\METScomms\MainProgram.cs:line 23
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

So after discovering that there is a third page to the basic intro (after page two) I now have the programmatically setup container working… At least it’s a start…

Comments:

Nick Kellett 2009-05-07 12:46:29

Hi Simeon, I get the same error. I think it could be related to the fact that I have two app.config files in different projects. Perhaps it is looking in the wrong one? I too got this working by programmatically adding the components but would like to use the app.config file. Have you figured it out since you posted this? Thanks

Nick


Simeon 2009-05-07 13:00:05

I left the project there, but gave my code to another developer, who progressed the project. Looking at his code I see he loads a XLM file via this code:

string configPath = Path.Combine(RegistryHelper.GetConfigurationFolder(), Properties.Resources.Client_Windsor_Configuration_FileName); _container = new WindsorContainer(new Castle.Windsor.Configuration.Interpreters.XmlInterpreter(configPath));


Nick Kellett 2009-05-08 02:18:35

Thanks Simeon, that was helpful - when I specify the path it works fine. The bug is related to multiple config files. I think my AppDomain config file is different from the one where I specify the castle element. I appreciate your response.


Richard Dingwall 2010-11-10 09:19:06

I had this issue when my config file name didn’t match the exe e.g. foo.bar.exe + bar.config. Took ages to track down, very annoying!