I had the same question some time ago and finally i ended creating a registry class on each project and calling them in cascade.
I ll update with some code when i get home.
Update
I had 3 projects (Web, Services and Data) but i did not want to add a reference to Data in my Web project for example, so what i did is that every project is responsible of registering it s own Interfaces.
For example, In my Web project i created the class WebRegistry that not only register its own types but also calls the ServicesRegistry class in my Services project and so on.
WebRegistry:
public class WebRegistry : Registry
{
public WebRegistry()
{
ObjectFactory.Configure(x =>
{
//call to ServicesRegistry in my services project
x.AddRegistry(new ServicesRegistry());
//Register your web classes here
ForRequestedType... blablablabla
});
}
}
ServicesRegistry:
public class ServicesRegistry : Registry
{
public ServicesRegistry()
{
ObjectFactory.Configure(x =>
{
x.AddRegistry(new DataRegistry());
//Register your services classes here
ForRequestedType... blablablabla
});
}
}
And finally the DataRegistry:
public class DataRegistry : Registry
{
public DataRegistry()
{
ObjectFactory.Configure(x =>
{
ForRequestedType blablbabla....
});
}
}
I think this way everything is completely idependant and you only need one call to the webregistry in your global.asax to configure the entire application:
/// <summary>
///
/// </summary>
public class Bootstrapper
{
/// <summary>
///
/// </summary>
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(x =>
{
x.AddRegistry(new WebRegistry());
});
}
}
Global.asax:
protected void Application_Start()
{
Bootstrapper.ConfigureStructureMap();
}