0

I am working on a .Net Bot Framework bot. I have a login service, but it is currently pretty drawn out and inefficient for the user. Thus, im trying to convert it to an Adaptive-Card. My code goes;

else if (lowerMessage == "test card")
        {
            var replyMessage = context.MakeMessage();
            AdaptiveCard card = new AdaptiveCard();

            AdaptiveTextInput usernameInput = new AdaptiveTextInput()
            {
                Id = "Username"
            };

            AdaptiveTextInput passwordInput = new AdaptiveTextInput()
            {
                Id = "Password"
            };
            card.Body.Add(new AdaptiveContainer()
            {
                Items = new List<AdaptiveElement>()
                {
                    new AdaptiveColumnSet()
                    {
                        Columns = new List<AdaptiveColumn> ()
                        {
                            new AdaptiveColumn()
                            {
                                Items = new List<AdaptiveElement>()
                                {
                                    new AdaptiveTextBlock()
                                    {
                                        Text = "Username?"
                                    },
                                    usernameInput,
                                    new AdaptiveTextBlock()
                                    {
                                        Text = "Password?"
                                    },
                                    passwordInput

                                }
                            }
                        }
                    }
                }
            });
            card.Actions.Add(new AdaptiveSubmitAction()
            {
                Title = "Submit",
                Data = usernameInput.Value + "/" + passwordInput.Value
            });

            Attachment adAttachment = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content = card
            };

            replyMessage.Attachments = new List<Attachment>()
            {
                adAttachment
            };
            //context.Wait(MessageReceivedAsync);
            await context.PostAsync(replyMessage);

This is returning a null reference, and I'm pretty sure its because im not setting a wait, or a callback for the submit. Not sure how to do this, however, and days of forum trawling havent yielded many results.

Thanks

  • Did you succeed at debugging your code? Could you eventually locate the exception then? – rudolf_franek Mar 19 '18 at 09:46
  • what does "returning a null reference" mean? I don't see a `return` anywhere. Do you mean a `NullReferenceException` is thrown? Then this is a duplicate and you should at least include the **stack trace** of the exception that tells you *where* it was thrown. – René Vogt Mar 19 '18 at 09:47
  • Expanding on @rudolf_franek's comment, where does the stack trace say the exception has occurred? – Jon Mar 19 '18 at 10:02
  • null reference was returned by bot, and the error handler i have it wrapped in (so it doesnt just say "my bot code has an issue") the stack trace is; – Rarceth Mar 19 '18 at 10:22
  • 'bject reference not set to an instance of an object. at Microsoft.Bot.Sample.SimpleEchoBot.RootDialog.d__1.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume`1.d__5.MoveNext() — End of stack trace from previous location where ex…' – Rarceth Mar 19 '18 at 10:22
  • also, @RenéVogt, I feel that the duplication tag was perhaps applied hastily, as I understand the connotations behind a null reference, I just think its because I am not setting a variable properly as part of the adaptive cards submit, which I dont have good syntax resources for – Rarceth Mar 19 '18 at 10:32

0 Answers0