public class RepositoryRegistry : Registry
{
public RepositoryRegistry()
{
Scan(x =>
{
x.Assembly("MyApp.Data");
x.TheCallingAssembly();
x.WithDefaultConventions();
x.AddAllTypesOf(typeof(ILookupRepo<>));
});
var tmp = ObjectFactory.GetInstance<ILookupRepo<User>>();
Debug.WriteLine(ObjectFactory.WhatDoIHave());
}
}
收到此错误:
{"StructureMap Exception Code: 202 No Default Instance defined for PluginFamily MyApp.Data.Repositories.Lookup.ILookupRepo`1[[MyApp.Data.Context.User, MyApp.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], TolMobile.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}
StructureMap 似乎无法解决IAnything<T>
。有什么理由会停止工作吗?我以完全相同的方式在另一个项目中使用了它,它解决了。唯一的区别是我现在使用的 StructureMap 版本更新...