I have a simple mvc application that has 3 layer
- Ui => has refrence to Common And Services
- Common
- Services => has refrence to Common
I define my Service Contracts in Common layer and implement it in services layer
//Common layer
public interface IPersonService
{
void Foo();
}
//Services layer
public classPersonService:IPersonService
{
void Foo()
{
//To DO
}
}
In my Global.asax I write this code for initial Structuremap container
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
}
Now,in my controller when I want get instance from IPersonService like this
var personService= ObjectFactory.GetInstance<IPersonService>();
I get this error
No default Instance is registered and cannot be automatically determined for type '*.IPersonService'
Is there any idea for resolve this problem?