Using StructureMap 3.0.3.116 to initialize services with custom IRepository<,> with SharpRepository, structuremap still cannot find concrete class using the default convention.
public interface IBlogImageRepository : IRepository<BlogImage,int>
{
}
public class BlogImageRepository :
ConfigurationBasedRepository<BlogImage, int>, IBlogImageRepository
{
Error:
No default Instance is registered and cannot be automatically determined for type 'My.Assembly.Repositories.IBlogImageRepository'
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.Assembly("S3.Libs");
scan.IncludeNamespace("S3.Libs.Repositories");
scan.IncludeNamespace("S3.Libs.Services");
scan.WithDefaultConventions();
scan.ConnectImplementationsToTypesClosing(typeof (IRepository<,>));
});
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
});
Looks like I got it to work by adding [DefaultConstructor] attribute to the constructor that had no parameters. It was trying to use the greediest constructor.