Autofac IComponentContext.Registrations is empty

本文关键字:empty is Registrations IComponentContext Autofac | 更新日期: 2025-05-08 15:43:10

我的核心项目中有IDispatcher接口:

public interface IDispatcher
{
    ...
}

在基础设施项目中,我正在实施:

public class AutofacDispatcher : IDispatcher
{
    private readonly IComponentContext container;
    public AutofacDispatcher(IComponentContext container)
    {
        this.container = container;
    }
        ...
}

现在,当我打电话时:

var dispatcher = container.Resolve<IDispatcher>();

Dispatcher内部的专用IComponentContext为空,并且没有注册。

为什么会这样,我该如何让它发挥作用?

Autofac IComponentContext.Registrations is empty

好吧,我自己想好了。

我有太多的注册在集装箱(超过7千)。

我设法只引用了我的程序集,现在它开始工作了。