maui
maui copied to clipboard
iOS The type initializer for 'Microsoft.Maui.Controls.Shapes.Shape' threw an exception. on latest .NET 7
Description
On our project on iOS this code throws an exception using latest .NET 7 Xcode 14.1, Xamarin.iOS 16.0.0.72, VS Version 17.5.0 Preview 1.0
Android and UWP are fine... Maui Sample project also works fine on iOS
builder.UseMauiApp<App>().ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseMauiCommunityToolkit()
.ConfigureEssentials(essentials =>
{
essentials.UseVersionTracking();
});
Steps to Reproduce
Not sure
Link to public reproduction project repository
NA
Version with bug
7.0 (current)
Last version that worked well
7.0 Release Candidate 2
Affected platforms
iOS
Affected platform versions
iOS 15.4
Did you find any workaround?
No
Relevant log output
{System.TypeInitializationException: The type initializer for 'Microsoft.Maui.Controls.Shapes.Shape' threw an exception.
---> System.MissingFieldException: Field not found: Microsoft.Maui.IPropertyMapper`2<Microsoft.Maui.IShapeView, Microsoft.Maui.Handlers.IShapeViewHandler> Microsoft.Maui.Handlers.ShapeViewHandler.Mapper Due to: Could not find field in class
--- End of inner exception stack trace ---
at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.RemapForControls(MauiAppBuilder builder)
at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.SetupDefaults(MauiAppBuilder builder)
at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.UseMauiApp[App](MauiAppBuilder builder)
at AssessorApp.MauiProgram.CreateMauiApp() in C:\Users\User\workspace\project\MauiProgram.cs:line 13
at AssessorApp.AppDelegate.CreateMauiApp() in C:\Users\User\workspace\project\project\Platforms\iOS\AppDelegate.cs:line 16
at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
at AssessorApp.Program.Main(String[] args) in C:\Users\User\workspace\project\project\Platforms\iOS\Program.cs:line 15}
base: {System.SystemException}
TypeName: "Microsoft.Maui.Controls.Shapes.Shape"
Hi @paulhavey. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
I ran into the same problem today as well.
I ran into the same problem today as well.
Could you share more information or a small sample where reproduce the issue?
Hi @paulhavey. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
It looks like the issue here is if you specify net7.0-ios15.4 as a TFM
I'm not sure if that's supported. @rolfbjarne thoughts?
Sorry this took so long.


I am targeting a Mac running Ventura OS and targeting the IPhone 14 Plus IOS 16 Simulator.
@mancda can you paste your csproj file here? and/or attach a binlog? https://github.com/xamarin/xamarin-macios/wiki/Diagnosis
See attached. binlogandcsproj.zip
@mancda you need to change this

remove the 15.4 from net7.0-ios
Hi @paulhavey. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
That fixed it for me. Thank you very much.
It looks like the issue here is if you specify
net7.0-ios15.4as a TFMI'm not sure if that's supported. @rolfbjarne thoughts?
Yeah, that probably won't work.
I've filed https://github.com/xamarin/xamarin-macios/issues/16802 to see if we can show a better error message.
Closing this issue in favor of https://github.com/xamarin/xamarin-macios/issues/16802
I've also engaged with the IDE teams on this one to provide a better experience with the TFM dropdown options.