发生错误:
无法从程序集'Services,Version = ....中加载类型'Services.IBaseService`1'。
我尝试使用单个通用类型(IBaseService< T >
),它工作正常。
有人可以帮我如何注入这种通用对象吗?
我的界面:(我的Impl :(命名空间Services.Interface))
public interface IBaseService<T, O> where T : class where O: class
{
}
public interface IInvoiceService : IBaseService<Invoice, OInvoice>
{
}
我的Impl :(命名空间Services.Impl)
public class BaseService<T, O> where T: class where O: class
{
}
public class InvoiceService : BaseService<Invoice, OInvoice>, IInvoiceService
{
}
我的注入代码:
...
var assembly = Assembly.GetAssembly(typeof(InvoiceService));
builder.RegisterAssemblyTypes(assembly)
.Where(x => x.Namespace != null
&& x.Namespace.EndsWith("Services.Impl"))
.AsImplementedInterfaces()
.InstancePerRequest();
...