Solution: Is Visual Studio building all the projects every time?

1. Go to Tools -> Options
2. Under Projects & Solutions -> Build and Run set both build file verbosity and log file verbosity to “Diagnostic”.
3. Build the solution and look at the first line in the output window, it may be telling you that a file is missing and therefore rebuilding everything

Advertisements

Must create DependencySource on same Thread as the DependencyObject.

Stumped me for a bit because I wasn’t expecting this as a result of the change I made. I was creating a colour in my ViewModel like this:

private readonly Brush[] colours = new[] { Brushes.Black, Brushes.DarkBlue };

But then wanted to use some more funky colours so changed it to:

private readonly Brush[] colours = new[] { new SolidColorBrush(Color.FromRgb(0x04, 0x81, 0x9E)), new SolidColorBrush(Color.FromRgb(0xEC, 0xFC, 0x00)) };

Because I was no longer referencing the static brushes and instead creating them when this class is instantiated (which happened to be on a non UI thread), this caused the above ArgumentException (which had a stack trace and values that really didn’t point to where the error actually occured).

Fixing it meant doing it properly 🙂 I created the brushes in my View and used Style triggers to choose the appropriate brush based on a value in my ViewModel.