猿问

Microsoft Bot 框架程序集参考

我有以下代码,但来自 Microsoft bot 创建教程https://docs.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-quickstart


当我复制并粘贴它时,我的 using 语句似乎没有在示例中被使用?我已经尝试添加它建议的 using 语句,但我认为这不是必需的。我有错误[BotAuthentication]和Activity“找不到类型或命名空间名称‘活动’”等


我也安装了金块包。


using System.Net;

using System.Net.Http;

using System.Threading.Tasks;

using System.Web.Http;

using Microsoft.Bot.Builder.Dialogs;

using Microsoft.Bot.Connector;

using System;

using System.Linq;

using System.Configuration;

using Microsoft.Bot.Builder.CognitiveServices.QnAMaker;

using System.Web.Services.Description;

using Microsoft.Bot.Builder.PersonalityChat;

using Microsoft.Bot.Builder.PersonalityChat.Core;


namespace BenTestBot

{

    [BotAuthentication]

public class MessagesController : ApiController

{

    public async Task<HttpResponseMessage> Post([FromBody]Activity activity)

    {

        if (activity.GetActivityType() == ActivityTypes.Message)

        {


            //await Conversation.SendAsync(activity, () => new Qna_Rich_Cards.Dialogs.QnaDialog().DefaultIfException());

            await Conversation.SendAsync(activity, () => new Dialogs.BasicPersonalityChatBotDialog().DefaultIfException());


        }

        else

        {

            await HandleSystemMessageAsync(activity);

        }

        var response = Request.CreateResponse(HttpStatusCode.OK);

        return response;

    }


BIG阳
浏览 183回答 1
1回答

慕村225694

如果您已经安装了 nuget 软件包,那么它不应该在那里。也许您应该检查软件包的版本并尝试更新软件包。要使 [BotAuthentication] 和活动正常工作,您需要 Microsoft.Bot.Connector;在您的情况下已经存在,因此请尝试更新。
随时随地看视频慕课网APP
我要回答