Thank you. This issue is resolved by following this link: https://learn.microsoft.com/en-us/dotnet/maui/migration/multi-project-to-multi-project?view=net-maui-8.0#add-package-references
MAUI .NET 8 on iOS - throwing an exception
Aneetha
65
Reputation points
I have created a new MAUI .NET 8 project and migrated the Xamarin forms project code. When tried to run the project with the iOS simulator with Jetbrains Rider, which threw the exception below,
- 2024-06-26 18:04:18.531738+0530 SKM_MOBILE[13228:278431] Could not register the assembly 'Microsoft.Maui.Controls': System.TypeLoadException: Could not resolve type with token 010000c8 from typeref (expected class 'Microsoft.Maui.Graphics.Platform.PlatformGraphicsView' in assembly 'Microsoft.Maui.Graphics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') at System.Reflection.RuntimeModule.GetTypes() at System.Reflection.Assembly.GetTypes() at Registrar.DynamicRegistrar.CollectTypes(Assembly assembly) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 219 at Registrar.Registrar.RegisterAssembly(Assembly assembly) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Registrar.cs:line 2527 2024-06-26 18:04:18.546774+0530 SKM_MOBILE[13228:278431] Could not register the assembly 'Microsoft.Maui': System.TypeLoadException: Could not resolve type with token 010000c8 from typeref (expected class 'Microsoft.Maui.Graphics.Platform.PlatformGraphicsView' in assembly 'Microsoft.Maui.Graphics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') at System.Reflection.RuntimeModule.GetTypes() at System.Reflection.Assembly.GetTypes() at Registrar.DynamicRegistrar.CollectTypes(Assembly assembly) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:line 219 at Registrar.Registrar.RegisterAssembly(Assembly assembly) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Registrar.cs:line 2527 2. Unhandled Exception: 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 SKM_MOBILE.MauiProgram.CreateMauiApp() in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/MauiProgram.cs:line 10 at SKM_MOBILE.AppDelegate.CreateMauiApp() in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/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) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at SKM_MOBILE.Program.Main(String[] args) in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/Platforms/iOS/Program.cs:line 21 2024-06-26 18:04:45.050897+0530 SKM_MOBILE[13228:278431] Unhandled managed exception: The type initializer for 'Microsoft.Maui.Controls.Shapes.Shape' threw an exception. (System.TypeInitializationException) 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 SKM_MOBILE.MauiProgram.CreateMauiApp() in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/MauiProgram.cs:line 10 at SKM_MOBILE.AppDelegate.CreateMauiApp() in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/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) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94 at SKM_MOBILE.Program.Main(String[] args) in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/Platforms/iOS/Program.cs:line 21 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 (System.MissingFieldException)
is there any solution to resolve this issue?