Hey ya!
In the web there are a lot of tutorials which can help you with switching indexes from Lucene to Solr. In most of them we have part where we need to edit Global.asax file and change inheritance to use IOC container. Here is the snippet from Sitecore documentation about which I am talking about. It is totally OK, but we have to keep in mind that method Application_Start from Global.asax.cs will not be triggered, so for instance when we want to register our custom routes in Global.asax.cs - we can't do it now. Now we should do it by usage pipelines etc
Workaround
There is smart workaraound which allow us to use Globax.asax.cs in traditional way. Instead changing inheritance within Global.asax, we can use approach presented below:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
var container = new WindsorContainer();
try
{
//this line is crucial. it initialize IOC for Solr
new Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorSolrStartUp(container).Initialize();
}
catch (Exception ex)
{
Sitecore.Diagnostics.Log.Error("Solr init error", ex, this);
}
}
}
In this code we've initialized IOC components for Castle Windsor to Solr and now it should work correctly.
It is worth to say that we can do it for other IOC Containers as well. We just have to use proper dll. More details about rest of components are in table.
See you soon!