如何为多个模块分辨率配置Autofac for Service结构

时间:2019-01-09 15:48:34

标签: autofac azure-service-fabric autofac-module

我有一个Service fabric项目,并且我决定使用Autofac通过DI注入我的所有配置。我已经使用过this,而且效果很好。现在,我决定进一步前进,并使用Autofac注入我所有服务的依赖项。问题在于那些依赖关系还取决于配置依赖关系,我不知道如何设置Autofac模块使其正常工作。 到目前为止,这是我的代码:

//this is how i use the config injected dependency
var connectionString = this._configProvider.GetConnectionString();

//this is the other dependency I want to setup Di for
var busMonitor = new BusMonitor(connectionString);

请注意,BusMonitor对象取决于connectionString,这就是问题所在,请参阅,我不知道如何配置Module使其能够在Program.cs上注册

这是我要实现的目标:

public BusMonitor(IConfigProvider<SomeStatefulService> configProvider)
        {
            this._configProvider = configProvider;
        }

但是我收到此错误: 激活特定注册期间发生错误

0 个答案:

没有答案
相关问题