question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] TypeLoadException in MacCatalyst

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the “Reporting a bug” section on Contributing file?

Current Behavior

In a brand new Maui project on MacCatalyst, I am getting a TypeLoadException when the program starts up. The error message says:

“Could not set up parent class, due to: Invalid generic instantiation assembly:/bin/Debug/net7.0-maccatalyst/maccatalyst-x64/SkiaSharpTest.app/Contents/MonoBundle/Microsoft.Maui.dll type:ViewHandler`2 member:(null)”

The source of the error says it is from CommunityToolkit.Maui. here is the stack trace

" at CommunityToolkit.Maui.AppBuilderExtensions.<>c.<UseMauiCommunityToolkit>b__0_0(IMauiHandlersCollection h) in /_/src/CommunityToolkit.Maui/AppBuilderExtensions.shared.cs:line 28\n at Microsoft.Maui.Hosting.HandlerMauiAppBuilderExtensions.HandlerRegistration.AddRegistration(IMauiHandlersCollection builder)\n at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory.CreateHandlerCollection(IEnumerable1 registrationActions)\n at Microsoft.Maui.Hosting.Internal.MauiHandlersFactory..ctor(IEnumerable1 registrationActions)\n at Microsoft.Maui.Hosting.HandlerMauiAppBuilderExtensions.<>c.<ConfigureMauiHandlers>b__1_0(IServiceProvider sp)\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)\n at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)\n at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)\n at System.Collections.Concurrent.ConcurrentDictionary2[[System.Type, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type key, Func2 valueFactory)\n at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)\n at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)\n at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)\n at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)\n at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)\n at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IMauiHandlersFactory](IServiceProvider provider)\n at Microsoft.Maui.MauiContext.<.ctor>b__2_0()\n at System.Lazy1[[Microsoft.Maui.IMauiHandlersFactory, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ViaFactory(LazyThreadSafetyMode mode)\n at System.Lazy1[[Microsoft.Maui.IMauiHandlersFactory, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)\n at System.Lazy1[[Microsoft.Maui.IMauiHandlersFactory, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].CreateValue()\n at System.Lazy`1[[Microsoft.Maui.IMauiHandlersFactory, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_Value()\n at Microsoft.Maui.MauiContext.get_Handlers()\n at Microsoft.Maui.Platform.ElementExtensions.SetHandler(INativeObject nativeElement, IElement element, IMauiContext context)\n at Microsoft.Maui.Platform.ElementExtensions.SetApplicationHandler(IUIApplicationDelegate platformApplication, IApplication application, IMauiContext context)\n at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions)\n at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)\n at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)\n at SkiaSharpTest.Program.Main(String[] args) in /Users/gktval/Projects/SkiaSharpTest/Platforms/MacCatalyst/Program.cs:line 13"

Any ideas what I can do to resolve this? It seems like this just started happening after updating to Maui 7.0.86.

Expected Behavior

No error

Steps To Reproduce

Create a new Maui Project in Visual Studio. Add CommunityToolkit.Maui nugget. Debug for MacCatalyst.

Link to public reproduction project repository

NA

Environment

- .NET MAUI CommunityToolkit: 5.0 and 5.1
- OS:MacCatalyst
- .NET MAUI: 7.0.86

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
VladislavAntonyukcommented, May 25, 2023

we plan a new release tomorrow. Let’s see if it works to solve the issue.

1reaction
vhugogarciacommented, May 25, 2023

Hello @gktval ,

I downloaded your brand new project where you say the error occurs, however, I was unable to reproduce it locally.

Please make sure you are using the follow app versions in macOS:

  • Visual Studio Community 2022 for Mac, Version 17.5.6 (build 3)
  • .NET SDK (Arm64), Versions: 7.0.302
  • Xamarin.Mac, Version: 9.3.0.6
  • XCode 14.3
  • macOS Ventura 13.4
  • Xamarin.iOS, Version: 16.4.0.6

And that you have installed the following workloads: image

I ran your demo project without issues. 😃

Regards, Victor

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.TypeLoadException error on Asp.Net MVC Visual ...
I am trying to transfer my ASP.NET MVC version 4.7 project to Visual Studio for Mac but i am getting this error. Can...
Read more >
Mac Catalyst app won't launch in Xcode
When I set the run destination to My Mac Catalyst and run I immediately see a dialog stating: "The LaunchServices launcher has returned...
Read more >
Could not resolve type with token 01000021 from typeref
I am trying to create virtual appointments based on this documentation: ...
Read more >
System.TypeLoadException
hello. when i migrated form a windows laptop to a mac and try to use old projects in visual studio i encountered with...
Read more >
MacCatalyst required for MAUI on macos? : r/dotnet
Hi Thought I would have a look at MAUI as I work in a DevOps team with macs and Win PCs but we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found