[Solved] No exception in method call UIImage.LoadFromData(null) [closed]


You either have a global exception handler, or you are calling that from a background thread and not awaiting the call to the async method so your exception is being swallowed. Example, just doing this:

public override void ViewDidLoad()
{
    base.ViewDidLoad();

    var x = UIImage.LoadFromData(null);
}

you will get a System.ArgumentNullException: Value cannot be null exception, but if you instead do:

public override void ViewDidLoad()
{
    base.ViewDidLoad();

    Task.Run(() => {
        var x = UIImage.LoadFromData(null);
    });
}

the exception will be swallowed and you will never see it, even if you have a global exception handler. And this is by design. Any fire and forget task that is not awaited will swallow, i.e. not re-throw, any exceptions raised in the fire and forget task.

Awaiting the task will raise the exception:

public override async void ViewDidLoad()
{
    base.ViewDidLoad();

    await Task.Run(() => {
        var x = UIImage.LoadFromData(null);
    });
}

0

solved No exception in method call UIImage.LoadFromData(null) [closed]