xaml prser error

Eduardo Gomez 3,426 Reputation points
2020-01-17T06:56:30.553+00:00

Hello how is evreryone doing?

I am in the last part of the development of my app, and I may need some help @Fay Wang - MSFT (Why the way thank you for all the help)

  1. In the LoginPage.xaml, it cannot find my VM (View Model) and throws me the error "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Windows.UI.Xaml.Markup.XamlParseException: The text associated with this error code could not be found.
    Cannot create instance of type 'uwpEvernote.NotesVM' [Line: 14 Position: 21]
    at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
    at uwpEvernote.View.NotesPage.InitializeComponent()
    at uwpEvernote.View"
    is very difficult to program, when Visual Stuido act very stupid and cannot find you VM (Virtual Models)
  2. In the NotesPage.xaml.cs, I need to call the "OnActivated" method, to see if the userID is empty or not. The UserID is defined as a string in the App.cs, but I am confused where to check that.

I am copying my repository to see if you coud help me.please link text

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Fay Wang - MSFT 5,221 Reputation points
    2020-01-17T09:14:21.047+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    it cannot find my VM (View Model) and throws me the error

    By checking your code, I got this exception in NotesPage.xaml and it is caused by SQLiteConnection in the NotesVM.cs. For example, because you don't have any data in your database, the method conn.Table< NoteBook>().ToList() will throw the exception, so you could add try...catch to prevent continued execution without data.

    NotesVM.cs:

    public void ReadNotebooks()   
    {  
        using (var conn = new SQLiteConnection(DatabaseHelper.dbFile)) {​  
            try   
            {​  
                var notebooks = conn.Table().ToList();​  
                NoteBooks.Clear();​  
                foreach (var item in notebooks)​  
                {​  
                    NoteBooks.Add(item);​  
                }​  
            } catch (Exception ee) {​  
                string info = ee.Message;​  
            }  
        }​  
    }  
    

    The UserID is defined as a string in the App.cs, but I am confused where to check that

    When you want to check it, you can call the App.UserId to see if it is empty or not.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.