dependency-injectioninversion-of-controlservice-locatorcommon-service-locator

IoC container conflict


In my current project I'm using SolrNet and OAuth.Net. Both libraries use Common Service Locator. SolrNet set as a locator provider a custom IoC container implementation. The locator provider for OAuth.Net is set in my code (currently I'm using Windsor as it is used in the examples). And the problem starts here because

ServiceLocator.SetLocatorProvider()

actually is replacing the ServiceLocator.Current static property value.

Any advice? What are the best practices in such a scenario?

Thanks in advance, Hristo


Solution

  • If you're already using Windsor, set up SolrNet using the included Windsor facility instead of the built-in container.