Bot Emualor" ExceptionMessage":"对象引用未设置为对象的实例。"," exceptionType":" System.NullReferenceException" ,

时间:2018-02-23 07:37:03

标签: azure-sql-database botframework

我想将对话存储在聊天机器人上并使用IActivityLogger。 代码如下:

public class EntityFrameworkActivityLogger : IActivityLogger
{
    Task IActivityLogger.LogAsync(IActivity activity)
    {
        IMessageActivity msg = activity.AsMessageActivity();
        using (BotApplicationSqlData.ConversationDataContext dataContext = new BotApplicationSqlData.ConversationDataContext())
        {
            var newActivity = Mapper.Map<IMessageActivity, BotApplicationSqlData.Activity>(msg);
            if (string.IsNullOrEmpty(newActivity.Id))
                newActivity.Id = Guid.NewGuid().ToString();
            dataContext.Activities.Add(newActivity);
            dataContext.SaveChanges();
        }
        return null;
    }
}

我收到错误的请求

  

&#39; https://botapplicationsqlexample.azurewebsites.net/api/messages&#39;失败:[500]内部服务器错误。

在调试时,它会显示Null Reference ExceptionObject reference not set to an instance of an object

对话存储在Azure数据库中,但Bot的结束没有回复。有人可以帮我这个吗?

0 个答案:

没有答案