Ankur
Ankur

Reputation: 43

UWP XAML How to handle Unhandle exception

I have a listview and I insert the item into listview. Between inserting of item my application crash and how unhandled exception and error "incorrect parameter". I don't understand where exactly this crash. How can I go deep in XAML unhandled exception?

                var messages = obj.Messages;
                messages.Reverse();
                AddMessagesToMessageList(openChatData, messages);
                if (obj.IsFirstTime && MessageList.Count > 0)
                {
                    ChatListSelectedIndex = -1;
                    SendFullAck();
                    await ScrollIntoViewWithDelayAsync(MessageList.Count - 1);
                }
                else if (MessageList.Count > 0)
                {
                    await ScrollIntoViewWithDelayAsync(messages.Count - 1);
                }

                if (obj.Messages.Count < 10)
                {
                    _isNoMoreChats = true;
                }
                CheckOpenChatDataRemainingMessages();
                _isDirty = false;



    private void AddMessagesToMessageList(AbstractChatData openChatData, 
    List<Message> messages)
    {
        try
        {
            ObjFactory.Instance.CreateLogger().Log("AddMessagesToMessageList Start", GetType().Name, false);
            foreach (var message in messages)
            {
                AddMessageToMessageList(openChatData, message, null);
            }
            ObjFactory.Instance.CreateLogger().Log("AddMessagesToMessageList End", GetType().Name, false);
        }
        catch (Exception ex)
        {
            ObjFactory.Instance.CreateLogger().Log("EX= " + ex.Message, GetType().Name);
        }
    }

enter image description here

enter image description here

enter image description here

Upvotes: 2

Views: 205

Answers (1)

Martin Zikmund
Martin Zikmund

Reputation: 39092

This problem is most commonly caused when XAML tree is being constructed. I would suggest trying to comment out parts of the XAML code and run the app to locate the problematic part. It is most likely caused by using a disallowed attribute or nesting.

You cannot dive deeper into the exception details as it happens in generated code, however I agree it would be useful if it were more descriptive.

You may post your XAML code if you want further help investigating the problem.

Upvotes: 1

Related Questions