iOS application getting crashed "Could not set up parent class, due to: Invalid generic instantiation" .net MAUI
Asked Answered
M

2

5

.net MAUI Project based on .net version 7 getting crashed while I am trying to deploy it on device. Below is the exception I am getting: enter image description here

Visual Studio for Mac version :17.4(build 2406) .net version: .net 7 iPhone 13, iOS 16.3 below are the packages being used: enter image description here

Crashlogs: Unhandled Exception: System.TypeLoadException: Could not set up parent class, due to: Invalid generic instantiation assembly:/private/var/containers/Bundle/Application/8849B149-36C8-4750-86DD-2AAC2A958F3D//Microsoft.Maui.dll type:ViewHandler2 member:(null) at CommunityToolkit.Maui.AppBuilderExtensions.<>c.b__0_0(IMauiHandlersCollection h) in /_/src/CommunityToolkit.Maui/AppBuilderExtensions.shared.cs:line 28 at Microsoft.Maui.Hosting.HandlerMauiAppBuilderExtensions.HandlerRegistration.AddRegistration(IMauiHandlersCollection builder) at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.CreateHandlerCollection(IEnumerable1 registrationActions) at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory..ctor(IEnumerable`1 registrationActions) at Microsoft.Maui.Hosting.HandlerMauiAppBuilderExtensions.<>c.b__1_0(IServiceProvider sp) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.<…>

Midrash answered 31/1, 2023 at 12:57 Comment(4)
To begin with, you can try to build in release mode instead of debug mode. If that doesn't work, please help provide more details on this issue like VS version, .NET version, iOS device information and the nuget packages.Elwaine
You have installed many packages so I can't judge if the issue still exists if add community toolkit package. You can try to create an empty project and add community toolkit package, then determine if the issue still exists. I suspect the issue is caused by the package Telerik.UI.for.Maui. You can refer to .NET MAUI Project - Could not set up parent class, due to: Invalid generic instantiation.Elwaine
@AlexandarMay-MSFT after further investigation of crash logs i found that there is an issue with CommunityToolkt.Maui package. Pasting the crashlogs in question.Midrash
If it's related with CommunityToolkt.Maui package, you can create an issue at github.com/CommunityToolkit/Maui/issues for help.Elwaine
A
5

In my case it was caused due to outdated MAUI workloads that was installed on the Mac. See the issue thread on Github for more info. Running the following command updated the workloads and resolved the issue for me (Ended up having to update my Mac and then update XCode to 15.4 as well):

sudo dotnet workload install android ios maui
Amery answered 3/9 at 8:34 Comment(0)
O
3

Degrading CommunityToolkt.Maui version from 4.0.0 to 3.1 resolves the issue

Outline answered 16/3, 2023 at 15:56 Comment(3)
It is 2024 and the problem just happened again. I had to downgrade from 9.1.0 to 9.0.3 although I did what CVStyrdom suggested.Speedometer
Ditto. Had to do the same. But the had workload issues too. This saved me github.com/dotnet/maui/issues/24981#issuecomment-2381922764. I had to uninstall all workloads reinstall and then revert the nuget to 9.0.3.Parthenope
Just downgrading wasn't enough for me either, deleting the obj and bin folder solved the issue for me.Bargeboard

© 2022 - 2024 — McMap. All rights reserved.