have you applied the IOC container in your Program ? Do you want to depend on a specific IOC, the common service locator released by Microsoft's mode and practice team on codeplex. The common service locator class library contains an interface for application and framework developers to reference service location sharing. This class library is abstracted on the IOC container and service locators. This class library allows an application to indirectly access without strong reference dependencies. The interface it defines is very simple:
namespace Microsoft. practices. servicelocation
{< br> Public interface iservicelocator: iserviceprovider
{< br> Object getinstance (type servicetype );
Object getinstance (type servicetype, string key );
ienumerable Object getallinstances (type servicetype);
tservice getinstance ();
tservice getinstance ( string key);
ienumerable getallinstances ();
}< BR >}
A servicelocator static class is also provided as a single access point:
NamespaceMicrosoft. Practices. servicelocation
{
Public Static ClassServicelocator
{
Private StaticServicelocatorprovider currentprovider;
Public StaticIservicelocator current
{
Get {ReturnCurrentprovider ();}
}
Public Static VoidSetlocatorprovider (servicelocatorprovider newprovider)
{
Currentprovider = newprovider;
}
}
}
Here, the server locator is used to remove the dependency between IOC and components. The most basic idea of a service locator is that an object locator knows how to control all services required by an application. The website now has
Commonly used IOC adapters. If you use castle, you can use Castle Windsor adaptor. If you are using unity, you can use unity adapter and spring. Net adapter,
Structuremap adapter and so on.
common service locator official: http://www.codeplex.com/CommonServiceLocator