How do you handle when the editor (xaml / design) in visual studio throws an argumentnullexception, "value cannot be null" ?
I am reading some values from the database using entity framework and storing them in an observable collection so I can bind to them from xaml. It is logic to suppose that there might not be any values in the collection so the exception is correct, right? Even if I have values in the database, the exception is still thrown because the editor (when viewing in design mode) is not running the application to get the values, which is still normal.
When I run the application, everything works fine but the exception is very annoying.
I also get an error, using a try catch when reading from the database, but only in editor (xaml) not when running the application, that says "The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. The stacktrace gets me into the entity data model itself. I am using mysql as a backend. This messagebox with the error is thrown everytime I type something (a character) in xaml !
My unit and integration tests all work fine.
Btw is this normal ?
EDIT: If I add the initialization of the viewmodel in the app resources (in app.xaml.cs but not in the app.xaml) it seems to work. I don't see the errors when I write the code in xaml or when I switch to design to see how it looks.