Why i am getting TypeInitializationException

Jassim Al Rahma 1,521 Reputation points
2023-03-29T17:39:30.2266667+00:00

Hi,

Why I astarted getting the below error when running my iOS app?

can anyone help please..

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 at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.RemapForControls(MauiAppBuilder builder)
  at at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.SetupDefaults(MauiAppBuilder builder)
  at at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.UseMauiApp[App](MauiAppBuilder builder)
  at MyApp.MauiProgram.CreateMauiApp() in /Users/jassim/Projects/MyApp/MyApp/MauiProgram.cs:8
  at MyApp.AppDelegate.CreateMauiApp() in /Users/jassim/Projects/MyApp/MyApp/Platforms/iOS/AppDelegate.cs:8
  at at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
  at at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
  at at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
  at MyApp.Program.Main(String[] args) in /Users/jassim/Projects/MyApp/MyApp/Platforms/iOS/Program.cs:13

Thanks,

Jassim

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,868 questions
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,316 Reputation points Microsoft Vendor
    2023-03-31T01:17:04.57+00:00

    Hello,

    As you @Jassim Al Rahma said, you can solved the problem after several delete obj and bin and restart VS for mac.

    Thanks for your sharing.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful