[英]Bot Framework AutoFac Dependency Issue C# (Multiple Container)
在我的應用程序啟動中,我具有以下代碼來注冊我的模塊。
Conversation.UpdateContainer(builder =>
{
builder.RegisterModule<MyModule>();
});
我正在使用具有以下代碼的InstrumentedLUIS。
var builder = new ContainerBuilder();
builder.Register(c => new BotFrameworkApplicationInsightsInstrumentation(CreateBasicSettings()))
.Keyed<IBotFrameworkInstrumentation>(InstrumentationType.Basic)
.SingleInstance();
builder.Register(c => new BotFrameworkApplicationInsightsInstrumentation(CreateSettingsWithCognitiveServices()))
.Keyed<IBotFrameworkInstrumentation>(InstrumentationType.Cognitive)
.SingleInstance();
_container = builder.Build();
由於上面的代碼,我的模塊注冊丟失了,而我隨后收到的對bot的每次調用都沒有注冊,所請求的服務未注冊,請使用可選。
由於我不了解最新的Autofac,請問有人可以指導我嗎?
添加DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); 在_container = builder.Build();之后 盡管這只是解決問題的第一步,但我建議您閱讀此按請求的生命周期范圍
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.