将聊天机器人连接到cosmos db后出错500

时间:2018-06-11 05:05:30

标签: c# azure botframework

将我的azure聊天机器人连接到azure cosmos数据库后出现问题,我试图在我的在线编辑器和本地视觉工作室上运行,但它在两个平台上都不起作用。

错误在这里:

System.TypeLoadException
Could not resolve type with token 01000060 (from typeref, class/assembly System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): Microsoft.Azure.Documents.Client.

代码:

protected void Application_Start()
{

 var uri = new Uri(ConfigurationManager.AppSettings["DocumentDbUrl"]);
    var key = ConfigurationManager.AppSettings["DocumentDbKey"];
    var store = new DocumentDbBotDataStore(uri, key);

    Conversation.UpdateContainer(
                builder =>
                {
                    builder.Register(c => store)
                        .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
                        .AsSelf()
                        .SingleInstance();

                    builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
                        .As<IBotDataStore<BotData>>()
                        .AsSelf()
                        .InstancePerLifetimeScope();

                });
}

1 个答案:

答案 0 :(得分:0)

查看此处的示例:https://github.com/Microsoft/BotBuilder-Azure/blob/master/CSharp/Samples/DocumentDb/Global.asax.cs它还注册了AzureModule。你试过了吗?

Conversation.UpdateContainer(
    builder =>
    {
        builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

        var store = new DocumentDbBotDataStore(docDbEmulatorUri, docDbEmulatorKey);

        builder.Register(c => store)
            .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
            .AsSelf()
            .SingleInstance();

        // Register your Web API controllers.
        builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
        builder.RegisterWebApiFilterProvider(config);

    });