I am getting below exception when loading my MAUI application.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
[mono-rt] at FFImageLoading.Maui.CachedImage.SetupOnBeforeImageLoading(TaskParameter& imageLoader, IImageSourceBinding source, IImageSourceBinding loadingPlaceholderSource, IImageSourceBinding errorPlaceholderSource)
[mono-rt] at FFImageLoading.Maui.Platform.CachedImageHandler.UpdateBitmap(CachedImageView imageView, CachedImage image, CachedImage previousImage)
[mono-rt] at FFImageLoading.Maui.Platform.CachedImageHandler.ConnectHandler(CachedImageView platformView)
[mono-rt] at Microsoft.Maui.Handlers.ViewHandler`2[[FFImageLoading.Maui.CachedImage, FFImageLoading.Compat.Maui, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null],[FFImageLoading.Maui.Platform.CachedImageView, FFImageLoading.Compat.Maui, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null]].OnConnectHandler(View platformView) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 76
[mono-rt] at Microsoft.Maui.Handlers.ViewHandler.OnConnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 204
[mono-rt] at Microsoft.Maui.Handlers.ElementHandler.ConnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 106
[mono-rt] at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 64
[mono-rt] at Microsoft.Maui.Handlers.ViewHandler`2[[FFImageLoading.Maui.CachedImage, FFImageLoading.Compat.Maui, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null],[FFImageLoading.Maui.Platform.CachedImageView, FFImageLoading.Compat.Maui, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
[mono-rt] at Microsoft.Maui.Handlers.ViewHandler`2[[FFImageLoading.Maui.CachedImage, FFImageLoading.Compat.Maui, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null],[FFImageLoading.Maui.Platform.CachedImageView, FFImageLoading.Compat.Maui, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[mono-rt] at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 41
[mono-rt] at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
I have created a sample demo with this issue
I have issue with redirecting the pages to MainPage
or HomePage
. If I load the MainPage
from App.xaml.cs
like below no issue.
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new MainPage();
}
}
But if I load the HomePage
from App.xaml.cs
like below I am getting the above exception related to FFImageLoading
.
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new HomePage();
}
}
HomePage has one ffimageloading
widget and I have added .UseFFImageLoading()
property on the MauiProgram.cs
.