Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime errors while runnning this project #23

Open
ghost opened this issue Apr 21, 2020 · 3 comments
Open

Runtime errors while runnning this project #23

ghost opened this issue Apr 21, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 21, 2020

Hello, I'm using VS2019 and I wanted to learn how to setup Azure AD with my web API. Here's a summary of what I had to do different to make it compile and work:

  • TodoListclient MainWindow.xaml.cs L42-43 (Remove the todo: in the AppConfig parameters)
  • TodoListclient MainWindow.xaml.cs L227: Grabbing from the text fiend caused a crash due to threads on run time, so I just hardcoded "test" for now, but I'm sure you can do better. :)
  • Nuget: Newtonsoft.json, align todolistclient and todolistservice to version 12.0.3
  • Nuget: Upgrade all Microsoft.Asp* to 5.2.7

It took me a few hours to sort this out, but nonetheless the README.md was good.

Thanks!

@tfierens
Copy link

tfierens commented Jun 13, 2020

To add to @yell0wc0w2's comments. Yes to point 1, 3 and 4.

Regarding point 2, I usually use MVVM and ICommand (or similar) but to resolve the code "as is" for the InvalidOperation regarding the code executing on a different thread, a quick fix is to change the following line:

var todoItem = new TodoItem() { Title = ToDoText.Text };

to:

`var title = string.Empty;

Dispatcher.Invoke(() =>
{
    title = TodoText.Text;
 });

var todoItem = new TodoItem() { Title = title };`

Not ideal but better than hardcoding a value and still don't understand how so many small glitches were left in there!

@tfierens
Copy link

tfierens commented Jun 13, 2020

Ok,

The System.InvalidOperationException: 'The calling thread cannot access this object because a different thread owns it. does not occur because of this line:

var todoItem = new TodoItem() { Title = ToDoText.Text };

It is actually due to the fact that the todo: causes both TodoListScope and TodoListBaseAddress variables to be null and causes other problems! Removing the todo: actually takes care of the problem.

@ghost
Copy link
Author

ghost commented Jun 13, 2020

Hey thanks for coming back to me! Glad you were able to sort it out quickly. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant