[Question] Microsoft.Bot.Connector.CardAction.set_Value() Throwing Exception
System Information (Required)
- SDK Language: .NET/C#
- SDK Version: 3.8.1.0
- Development Environment: LOCALHOST
Issue Description
Currently using AuthBot library (https://github.com/MicrosoftDX/AuthBot) for Azure Active Directory authentication with BotBuilder. When I use the sample provided in the GitHub repo for AuthBot the program compiles and works as expected but when I use the same piece of code in the bot I am creating I get an exception from Microsoft.Bot.Connector.CardAction.set_Value().
Code Example
Below is the code snippet that is causing the issue. Issue seems to occur at var message = await result;
public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> item)
{
var message = await item;
if (message.Text == "logon")
{
//endpoint v1
if (string.IsNullOrEmpty(await context.GetAccessToken(ConfigurationManager.AppSettings["ActiveDirectory.ResourceId"])))
{
await context.Forward(new AzureAuthDialog(ConfigurationManager.AppSettings["ActiveDirectory.ResourceId"]), this.ResumeAfterAuth, message, CancellationToken.None);
}
else
{
context.Wait(MessageReceivedAsync);
}
}
}
private async Task ResumeAfterAuth(IDialogContext context, IAwaitable<string> result)
{
var message = await result;
await context.PostAsync(message);
context.Wait(MessageReceivedAsync);
}
Steps to Reproduce
- Run bot using localhost in bot emulator
- Send message 'logon'
- Exception is thrown
Expected Behavior
After sending 'logon' the expected behaviour is to get a response from bot with instructions to authenticate:
Expected response in chat:

Actual Results
What actually happens is in the chat a response is sent "Exception: Stack is empty" with an exception thrown in Visual Studio
Chatbot reponse:

Visual Studio exception from debugger:

@operacha Hello, could you please post the code where you are constructing the adaptive card?
@JasonSowers
Would this be what you're looking for?
private List<CardAction> GetCardActions(string authenticationUrl, string actionType)
{
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value = authenticationUrl,
Type = actionType,
Title = "Authentication Required"
};
cardButtons.Add(plButton);
return cardButtons;
}
@operacha also what channel are you using?
I have tried to repro the issue., but it is working fine with me. can you check the version you are using?



Are you on VPN?
@msmohan I'm running version 3.6.5-alpha for authbot
@JasonSowers I'm using localhost:44353
I'm looking more for something like this method in the Authbot
protected virtual Task PromptToLogin(IDialogContext context, IMessageActivity msg, string authenticationUrl)
{
Attachment plAttachment = null;
switch (msg.ChannelId)
{
case "skypeforbusiness":
return context.PostAsync(this.prompt + "[Click here](" + authenticationUrl + ")");
case "emulator":
case "skype":
{
SigninCard plCard = new SigninCard(this.prompt, GetCardActions(authenticationUrl, "signin"));
plAttachment = plCard.ToAttachment();
break;
}
// Teams does not yet support signin cards
case "msteams":
{
ThumbnailCard plCard = new ThumbnailCard()
{
Title = this.prompt,
Subtitle = "",
Images = new List<CardImage>(),
Buttons = GetCardActions(authenticationUrl, "openUrl")
};
plAttachment = plCard.ToAttachment();
break;
}
default:
{
SigninCard plCard = new SigninCard(this.prompt, GetCardActions(authenticationUrl, "signin"));
plAttachment = plCard.ToAttachment();
break;
}
// return context.PostAsync(this.prompt + "[Click here](" + authenticationUrl + ")");
}
IMessageActivity response = context.MakeMessage();
response.Recipient = msg.From;
response.Type = "message";
response.Attachments = new List<Attachment>();
response.Attachments.Add(plAttachment);
return context.PostAsync(response);
}
I have two suggestions.,
- Check on AAD settings for any restrictions.
- I understand, it is not working for newer version., there is a high possibility that some of the older functions/methods changed. Let us know if you need help in identifying.
After reviewing all., This is not BotBuilder framework related issue. It should be filed under AuthBot, https://github.com/MicrosoftDX/AuthBot/issues

Closing the issue under bot-builder.
Issue was due to AuthBot and NOT BotBuilder framework. After updating the versions and references within the code the issue was resolved.
@operacha Thanks for sharing the source code with me, that enabled me to help you to identify the root cause.