maui
maui copied to clipboard
System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer'
Description
I've got following exceptions in a project I'm working on, so I tried to create repro with similar layout, but it doesn't throw the exception, however it doesn't show ListView
items either at least on Android. In the right brown Frame
is ListView
bound to the same collection as CollectionView
, with different DataTemplate
.
Steps to Reproduce
maui-android-handler-activator-issue.zip Unpack and build!
Version with bug
6.0 Release Candidate 3
Last version that worked well
Release Candidate 1
Affected platforms
Android
Affected platform versions
Android 9
Did you find any workaround?
no
Relevant log output
[0:] [20:18:45 WRN] System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer'.
at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.Maui.Hosting.Internal.MauiFactory.CreateInstance(ServiceDescriptor item) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 162
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(ServiceDescriptor descriptor) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 130
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 141
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 36
at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.GetHandler(Type type) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiHandlersFactory.cs:line 30
at Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform.CreateRenderer(VisualElement element, Context context, FragmentManager fragmentManager, LayoutInflater layoutInflater) in D:\a\_work\1\s\src\Compatibility\Core\src\Android\AppCompat\Platform.cs:line 344
[0:] [20:18:45 WRN] System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer'.
at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.Maui.Hosting.Internal.MauiFactory.CreateInstance(ServiceDescriptor item) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 162
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(ServiceDescriptor descriptor) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 130
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 141
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 36
at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.GetHandler(Type type) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiHandlersFactory.cs:line 30
at Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform.CreateRenderer(VisualElement element, Context context, FragmentManager fragmentManager, LayoutInflater layoutInflater) in D:\a\_work\1\s\src\Compatibility\Core\src\Android\AppCompat\Platform.cs:line 344
[0:] [20:18:45 WRN] System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer'.
at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.Maui.Hosting.Internal.MauiFactory.CreateInstance(ServiceDescriptor item) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 162
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(ServiceDescriptor descriptor) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 130
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 141
at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 36
at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.GetHandler(Type type) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiHandlersFactory.cs:line 30
at Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform.CreateRenderer(VisualElement element, Context context, FragmentManager fragmentManager, LayoutInflater layoutInflater) in D:\a\_work\1\s\src\Compatibility\Core\src\Android\AppCompat\Platform.cs:line 344
@anpin your repro project can‘t be unpacked. could you check for this and upload the correct one, thanks.
@kristinx0211 please try this maui-android-handler-activator-issue.zip
@anpin thanks for your update, I can repro this issue on android, ListView does not show, I'm not get the exception, on windows, the ListView is showing.
Here I'm running on another Android device. Can you share your Android screen shoot not Windows? What is your SDK version?
on android 12:
dotnet info:
on android 12:
dotnet info:
sorry I misread your original response, thought you said you can't reproduce it on Android
You can see original exception on Android if you configure logging as such
in csproj
use <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
and in MauiProgram.cs
use that builder.Services.AddLogging(l => l.AddConsole());
Adjusted repro here -> maui-android-handler-activator-issue.zip
I get the same exception when I want to migrate a Xamarin 5 project to MAUI. Unfortunately, this blocks me from migration to MAUI.
Used version: Visual Studio 2022 17.3.2
Starting on Android 12 results in the following exception:
System.MissingMethodException
Message=No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer'.
Update: This exception is catched by the library but it shows up in log. However, my crash at startup seems to be produced by another exception. For this one I get just the following info on Android (on Windows it works):
System.InvalidCastException: 'Specified cast is not valid.'
Verified this on Visual Studio Enterprise 17.6.0 Preview 7.0. Repro on Android 13.0 with below Project: 7799.zip
Exception:
[DOTNET] System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer'.
[DOTNET] at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
[DOTNET] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
[DOTNET] at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
[DOTNET] at System.Activator.CreateInstance(Type type, Boolean nonPublic)
[DOTNET] at System.Activator.CreateInstance(Type type)
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.CreateInstance(ServiceDescriptor item) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 162
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(ServiceDescriptor descriptor) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 130
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 141
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 36
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.GetHandler(Type type) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiHandlersFactory.cs:line 30
[DOTNET] at Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform.CreateRenderer(VisualElement element, Context context, FragmentManager fragmentManager, LayoutInflater layoutInflater) in D:\a\_work\1\s\src\Compatibility\Core\src\Android\AppCompat\Platform.cs:line 344
[Gralloc4] mapper 4.x is not supported
[DOTNET] [40m[1m[33mwarn[39m[22m[49m: Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform[0]
[DOTNET] System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer'.
[DOTNET] at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
[DOTNET] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
[DOTNET] at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
[DOTNET] at System.Activator.CreateInstance(Type type, Boolean nonPublic)
[DOTNET] at System.Activator.CreateInstance(Type type)
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.CreateInstance(ServiceDescriptor item) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 162
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(ServiceDescriptor descriptor) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 130
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 141
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 36
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.GetHandler(Type type) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiHandlersFactory.cs:line 30
[DOTNET] at Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform.CreateRenderer(VisualElement element, Context context, FragmentManager fragmentManager, LayoutInflater layoutInflater) in D:\a\_work\1\s\src\Compatibility\Core\src\Android\AppCompat\Platform.cs:line 344
[DOTNET] [40m[1m[33mwarn[39m[22m[49m: Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform[0]
[DOTNET] System.MissingMethodException: No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer'.
[DOTNET] at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
[DOTNET] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
[DOTNET] at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
[DOTNET] at System.Activator.CreateInstance(Type type, Boolean nonPublic)
[DOTNET] at System.Activator.CreateInstance(Type type)
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.CreateInstance(ServiceDescriptor item) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 162
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(ServiceDescriptor descriptor) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 130
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType, ServiceDescriptor single, IEnumerable`1 enumerable) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 141
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiFactory.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiFactory.cs:line 36
[DOTNET] at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.GetHandler(Type type) in D:\a\_work\1\s\src\Core\src\Hosting\Internal\MauiHandlersFactory.cs:line 30
[DOTNET] at Microsoft.Maui.Controls.Compatibility.Platform.Android.Platform.CreateRenderer(VisualElement element, Context context, FragmentManager fragmentManager, LayoutInflater layoutInflater) in D:\a\_work\1\s\src\Compatibility\Core\src\Android\AppCompat\Platform.cs:line 344
We were suddenly seeing this exception on CollectionView while it was wrapped in a RelativeLayout from MAUI Compatibility. We ended up refactoring the particular page and removing the RelativeLayout.
Same problem here, we have a big Xamarin Forms application that we need to convert to .NET MAUI, without the compatibility layer we have to refactor ever page before release on .NET MAUI, which is probably to big task
We are facing same problem after upgrading from Net 7 to Net 8.0.3, and the hole app is based on Relative Layouts, to be honest we are loosing time, effort and money dealing with Maui, the last thing we want to see is a compat library that stops working with a simple update.... :( I´ll try to find a workaround) Forms to Maui is really a pain.
any update on the above exception that is getting for frame renderer as i was also facing same.
I had a similar issue with Frames
System.MissingMethodException: 'No parameterless constructor defined for type 'Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer'.'
My workaround was to change the Frames to Borders
any updates? Noticing this on a client's project that I'm upgrading. also using compatibility mode and RelativeLayout with a ListView
I've resolved this by using a Grid implementation. Though, it might be good to reference this issue for people currently in the migration phase towards MAUI