Bot Framework文档出错处网址:https://docs.botframework.com/en-us/csharp/builder/sdkreference/attachments.html
出错代码:
1 Activity replyToConversation = message.CreateReply(translateToPigLatin("Should go to conversation, sign-in card")); 2 replyToConversation.Recipient = message.From; 3 replyToConversation.Type = "message"; 4 replyToConversation.Attachments = new List<Attachment>(); 5 List<CardAction> cardButtons = new List<CardAction>(); 6 CardAction plButton = new CardAction() 7 { 8 Value = "https://<OAuthSignInURL>", 9 Type = "signin", 10 Title = "Connect" 11 }; 12 cardButtons.Add(plButton); 13 SigninCard plCard = new SigninCard(title: "You need to authorize me", button: plButton); 14 Attachment plAttachment = plCard.ToAttachment(); 15 replyToConversation.Attachments.Add(plAttachment); 16 var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
注意到第13行的SigninCard函数。回到Visual Studio按F12查看函数定义:
注意到两个可选参数是:text,buttons。
根据上下文,代码应改为:
SigninCard plCard = new SigninCard(text:"You need to authorize me", buttons:cardButtons);
或直接写成:
SigninCard plCard = new SigninCard("You need to authorize me", cardButtons);