Question

How do I tell castle to pick up an interface implementation from the assemblies in the executing directory.
E.g.

How do I tell castle to find an implementation for ILog and then If I drop log4net among the assemblies in the executing directory, it should pick it and use it. Tomorrow if I decide to change log4net to Nlog it should pick up Nlog to log (both obviously should implement ILog)

Was it helpful?

Solution

You generally should not be so implicit. What if more than one impl is provided? What if you accidentally drop something you didn't intend to?

Having said that, you should use either config file to explicitly tell Windsor in XML which type fulfills your service, or use Binsor if you want more flexibility. There's no magical method in the code "for this service pick whatever implementation there is in any assembly in this folder" and it's very unlikely there will ever be.

And for the specific scenario of loggers, you can use Windsor's Logging facility.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top