question

EduardoGomez-1870 avatar image
0 Votes"
EduardoGomez-1870 asked ·

xaml prser error

Hello how is evreryone doing?

I am in the last part of the development of my app, and I may need some help @FayWang-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


windows-uwpwindows-uwp-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

FayWang-MSFT avatar image
0 Votes"
FayWang-MSFT answered ·

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.








· 2 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I want to check it at the beginning of the start of the app

0 Votes 0 ·

You can check it in the OnLaunched() event in App.xaml.cs.

0 Votes 0 ·