I am new to DI concept and new to structuremap. I am trying to full fill a scenario where all my interfaces are in AssemblyA
and all my implementations are in AssemblyB
. I want to use Structuremap to inject instance of AssemblyB
class in constructor which has dependency on interface from AssemblyA
public class Customer(ICustomerService)
{
}
ICustomerService
is in AssemblyA
and CustomerService
class is in assemblyB
. I want Structuremap to inject CustomerService
instance in this constructor. I am assuming that if the name of class is same as the name of interface prefixed with and I
. Structuremap will recognize it automatically.
I have written the following configuration.
x =>
{
x.Scan(scan =>
{
scan.Assembly("AssemblyA");
scan.Assembly("AssemblyB");
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
but it gives me error
StructureMap Exception Code: 202
No Default Instance defined for PluginFamily AssemblyA.ICustomerService, AssemblyA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
I want to use the default conventions and avoid registering each interface to a class.