Autofac 的新手,遵循了 Youtube 上的教程(收视率很高),但它抛出了一个异常,不知道为什么。
例外:
DependencyResolutionException:激活特定注册期间发生错误。有关详细信息,请参阅内部异常。注册:Activator = IDomainRepository (ReflectionActivator),Services = [Solution.Entities.IDomainRepository],Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime,Sharing = None,Ownership = OwnedByLifetimeScope
和
NoConstructorsFoundException:找不到类型“Solution.Entities.IDomainRepository”的可访问构造函数。
IDomainRepository
public interface IDomainRepository
{
List<Domain> GetAll();
string Insert(Domain obj);
bool Update(Domain obj);
bool Delete(string URL);
}
Run Code Online (Sandbox Code Playgroud)
域存储库
public class DomainRepository : IDomainRepository
{
public List<Domain> GetAll()
{
using (IDbConnection db = new SqlConnection(Helper.ConnectionString))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
return db.Query<Domain>("SELECT * FROM Domains", commandType: CommandType.Text).ToList();
}
}
public string Insert(Domain obj)
{
using (IDbConnection db = new …Run Code Online (Sandbox Code Playgroud)