Hello,
We are currently working with .NET MAUI and using the Syncfusion library for charting and the navigation drawer. Recently, we encountered an issue when trying to add multiple Syncfusion charts (e.g., SfCartesianChart/SfCircularChart) inside a container (Grid/StackLayout). This problem occurs only on macOS, specifically when we run the project in release mode. The app crashes when attempting to load the UI containing the container with the charts.
The issue does not arise if only one chart is added to the container. Our main application has UI regions, and the chart container is placed inside a NavigationDrawer. Additionally, there are layouts and custom templates to handle the UI. Interestingly, when we added multiple charts inside a sample project, it worked perfectly here. We believe the entire UI handling workflow in our main app is contributing to this crash.
We are sharing the crash log here. Please let us know if you have any insights regarding this issue.
Environment:
Framework: .NET MAUI
Platform: Windows, MacOS
Syncfusion version: 25.1.42
ErrorLog:
System.PlatformNotSupportedException:PlatformNotSupported_ReflectionEmit
at System.Reflection.Emit.AssemblyBuilder.EnsureDynamicCodeSupported()
at System.Reflection.Emit.DynamicMethod.Init(String,MethodAttributes,CallingConventions,Type,Type[],Type,Module,Boolean,Boolean)
at System.Reflection.Emit.DynamicMethod..ctor(String,Type,Type[],Type,Boolean)
at DryIoc.FastExpressionCompiler.LightExpression.ExpressionCompiler.TryCompileBoundToFirstClosureParam(Type delegateType,Expression bodyExpr,IParameterProvider paramExprs,Type[] closurePlusParamTypes,Type returnType,CompilerFlags flags)
at DryIoc.FactoryDelegateCompiler.CompileToFactoryDelegate(Expression expression,Boolean preferInterpretation)
at DryIoc.Container.System.IServiceProvider.GetService(Type serviceType)
at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider,Type)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[IAnimationManager](IServiceProvider)
at Microsoft.Maui.MauiContextExtensions.GetAnimationManager(IMauiContext mauiContext)
at Microsoft.Maui.Controls.ViewExtensions.GetAnimationManager(IAnimatable animatable)
at Microsoft.Maui.Controls.AnimationExtensions.Animate[Double](IAnimatableself,String name,Func`2 transform, Action`1 callback,UInt32 rate,UInt32 length,Easing easing,Action`2 finished, Func`1 repeat,IAnimationManager animationManager)
at Microsoft.Maui.Controls.AnimationExtensions.Animate(IAnimatableself,String name,Action`1 callback, UInt32 rate, UInt32 length, Easing easing, Action`2 finished,Func`1 repeat)
at Microsoft.Maui.Controls.AnimationExtensions.Animate(IAnimatable self, String name, Animation animation, UInt32 rate, UInt32 length, Easing easing, Action`2 finished,Func`1 repeat)
at Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.DrawerRightIn()
at Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.ToggleDrawer()
at Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.UpdateIsOpen()
at Syncfusion.Maui.NavigationDrawer.SfNavigationDrawer.OnSizeAllocated(Double width, Double height)
at Microsoft.Maui.Controls.VisualElement.SizeAllocated(Double width, Double height)
at Microsoft.Maui.Controls.VisualElement.UpdateBoundsComponents(Rect bounds)
at Microsoft.Maui.Controls.VisualElement.set_Frame(Rect value)
at Microsoft.Maui.Controls.VisualElement.ArrangeOverride(Rect bounds)
at Syncfusion.Maui.Core.SfView.ArrangeOverride(Rect bounds)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IView.Arrange(Rect bounds)
at Microsoft.Maui.Layouts.GridLayoutManager.ArrangeChildren(Rect bounds)
at Microsoft.Maui.Controls.Layout.CrossPlatformArrange(Rect bounds)
at Microsoft.Maui.Platform.MauiView.CrossPlatformArrange(Rect bounds)
at Microsoft.Maui.Platform.MauiView.LayoutSubviews()
--- End of stack trace from previous location ---
at UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr )
at UIKit.UIApplication.Main(String[] , Type , Type )
at MainApp.Mvp.Program.Main(String[] args)
Hi Habibur,
Thank you for reaching out.
We have investigated your query. The error you're encountering, System.PlatformNotSupportedException: PlatformNotSupported_ReflectionEmit, arises because your application is using System.Reflection.Emit, which is not supported on the macOS platform. This issue stems from the DryIoc library's attempt to use DynamicMethod. This further affects the animation management in Microsoft.Maui.Controls. Have you used any other libraries called DryIoc or the System.Reflection.Emit namespace elsewhere in your application? Kindly check these details in your application. We recommend refactoring your code to avoid System.Reflection.Emit, using conditional compilation like #if directives for the macOS platform, or checking for updates to the respective libraries you're using.
Have you add the multiple charts with DynamicMethod? Could you provide any additional information on how you add the charts in the container. This will helps us to provide better solution.
If you need further assistance, please let us know. We’re here to help.
Regards,
Dhanaraj Rajendran.