Why i am getting TypeInitializationException

Anonymous
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

Developer technologies | .NET | .NET MAUI
{count} votes

Answer accepted by question author
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,451 Reputation points Microsoft External Staff
    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.