Closed k4yaman closed 5 years ago
What happens if you throw an exception in the constructor or setters of the ViewModels, the error propagates all the way back up to the source, which is the ViewModelLocator who creates the ViewModels. This of course means that none of the viewmodels are created, and you get as you say an empty state, because there are no ViewModels to set it. You should see this stack trace in your debug output.
This means that if you want to do anything in constructors that is in the risk of throwing exceptions, you really need to handle it with try-catch. Getters and Setters shouldn't really throw exceptions imo.
Thanks :)
Hello, first of all thank you for this Project. I was able to extend a program with tabs to support multiple views of data. Anyway, sometimes inside the tabs, Exceptions are thrown which i can't seem to catch. The Program than starts up but doesn't show any tabs. I tried to catch them with
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
but it seems only some are caught. I built up the Program similar to your Demo and i would intentionally throw an Exception in your TabBase.cs Class to simulate errors (In a getter or setter or even in the constructor where I register commands). Then the Program gets caught up in a kind of empty Tabs state but it doesn't close or anything else where it passes by where I could log that error. The only thing that comes to my mind is putting a tryCatch around every kind of critical function to log the error. Do you have an Idea how to handle this properly? Kind Regards