Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] Null reference exception inside ICommand instantly terminates app #12774

Open
@Tommigun1980

Description

@Tommigun1980

Hi.

If a null reference exception happens inside an executed Command, the app terminates instantly, nothing is printed to the log, and no error propagation takes place. This is quite troublesome as it makes it hard to track down what happened and also impossible to log these errors for diagnostic purposes. You can't even catch this exception -- it literally just terminates on a null reference error, even when a debugger is connected, and shows absolutely no information about what went wrong. AppDomain.CurrentDomain.UnhandledException is also not invoked when this happens.

I have isolated this in the iOS simulator only, so don't know if it happens on a real device or on Android.

So please put this command in a view model and run it, and the app will terminate instantly on the null reference error, without any error handling being possible:

            this.TestCommand = new Command(() =>
            {
                try
                {
                    int[] ha = null;
                    var he = ha[0];
                }
                catch (Exception e)
                {
                    Console.WriteLine($"NEVER GETS HERE. Exception: '{e}'");
                    throw e;
                }
            });

The app only terminates if this code is inside an ICommand's action; null reference exceptions thrown from other places work normally. Also, the app gets instantly terminated only on a real null reference error, manually thrown errors propagate properly (including a manually thrown NullReferenceException) from Command actions.

Latest nightly XF version, iOS simulator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Cores/needs-info ❓A question has been asked that requires an answer before work can continue on this issue.t/bug 🐛

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions