I have a solution with multiple projects (a website and various other projects for DAL/BL etc). I’m trying to integrate Castle Windsor into the business logic to help me with writing some unit tests (I know unit tests and Castle Windsor should really be integrated before a project is finished, long story).
The problem I’m having is with the config files, I added the Castle Windsor config information to my BL projects app.config but when either the website or the unit tests (Both of which are in different projects) access the business logic Castle Windsor seems to look to at their own config files rather than the config file in the BL.
Surely I don’t have to add the config information to every project in my solution? That seems a bit pointless.
That can be easier than you think. Configure Castle Windsor in an standalone configuration file, for example “Components.config” and place it in some common location.
After that, you only need to add this file “as a link” in your projects. That’s achieved when you right-click in some folder or project and you choose “Add existing item”. In the file browser, check that in “Add” button there’s some arrow. Click there and choose “Add as a link”.
You’ll notice that your configuration file icon in Solution Explorer has some arrow, like a Windows shortcut. Now click on this linked file and open its properties, and in “Build action” choose “Copy always”. That’s all!
Don’t you know how to use standalone configuration files in Castle Windsor? Check this article:
Note that now you edit one file and you affect all linked ones at once!