-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
OnInitialActivate() Method seems to swallow exceptions #133
Comments
It shouldn't. Have you got a repro, please?
…On 8 June 2020 06:02:27 BST, FutureTD ***@***.***> wrote:
It seems the OnInitialActivate() Method swallows exceptions instead of
throwing or passing it to the Bootstrapper OnUnhandledException Method.
It would be nice if that method did not just swallow exceptions if
possible.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#133
|
Hey, thanks for the response I do not currently have a repo I was just testing It in my private project. for example:
When OnInitialActivate() gets ran I expect the application to crash or execute my bootstrap method
It does not at the moment, just seems to swallow the error. |
OK thanks, I'll see if I can repro on my end.
…On 8 June 2020 08:20:24 BST, FutureTD ***@***.***> wrote:
Hey, thanks for the response I do not currently have a repo I was just
testing It in my private project.
for example:
```
public class MyViewModel: Screen
{
protected override void OnInitialActivate()
{
throw new InvalidOperationException();
}
}
```
When OnInitialActivate() gets ran I expect the application to crash or
execute my bootstrap method
```
protected override void
OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{
Environment.Exit(0);
}
```
It does not at the moment, just seems to swallow the error.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#133 (comment)
|
Were you able to fix / verify this issue? |
I wasn't able to reproduce this, I'm afraid. Steps:
Please post some steps which I can follow which reproduces this. |
During further testing I figured out the problem was coming from the built-in conductor I was using: Conductor.Collection.OneActive I assumed that when you used this conductor with a TabControl and switched tabs, It would set the ActiveItem property to the selected screen which would in turn execute the OnInitialActivate() and OnActivate() methods. This does not seem to be the case as it seems to activate the first screen in the items list but for the rest those methods do not get called. It is not that it was swallowing exceptions, It was that the OnInitialActivate() and OnActivate() methods were not getting called at all.
and for the Window.xaml you would use
The application should crash when you switch to the Second Page unless I am mistaken, however it does not. |
Cool, that's why I asked for a repro in my first message. I'll look into this, thanks. The lifecycle stuff should be happening to all tabs. |
Were you able to reproduce the issue? |
Right, this happens when the ActiveItem is set from a binding (in this case, the switching between tabs is crucial), which causes the VM to be activated. It's because bindings swallow exceptions they encounter by default. I'm not sure what the best course of action is here: on the one hand this is how WPF works; on the other, we're doing rather more logic from a binding than is usual for WPF. |
The other complication is that we don't know when |
It seems the OnInitialActivate() Method swallows exceptions instead of throwing or passing it to the Bootstrapper OnUnhandledException Method.
It would be nice if that method did not just swallow exceptions if possible.
The text was updated successfully, but these errors were encountered: