I came across the below exception Dynamic code generation is not supported on this platform.
in iOS.
when trying to debug a .NET MAUI 8.0 application this happened after updating to the latest .net 8.0.7 runtime.
The exception in detail below
Exception has occurred: CLR/System.PlatformNotSupportedException
An unhandled exception of type 'System.PlatformNotSupportedException' occurred in System.Private.CoreLib.dll: 'Dynamic code generation is not supported on this platform.'
at System.Reflection.Emit.AssemblyBuilder.ThrowDynamicCodeNotSupported()
at System.Reflection.Emit.AssemblyBuilder.EnsureDynamicCodeSupported()
at System.Reflection.Emit.DynamicMethod.Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, Module m, Boolean skipVisibility, Boolean transparentMethod)
at System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility)
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.GetService[T](IServiceProvider provider)
at Microsoft.Maui.Controls.DispatcherExtensions.FindDispatcher(BindableObject bindableObject)
at Microsoft.VisualStudio.DesignTools.MauiTap.MauiHelpers.GetDispatcher(BindableObject bindableObject)
at Microsoft.VisualStudio.DesignTools.MauiTap.MauiHelpers.GetDispatcher(IWindow window)
at Microsoft.VisualStudio.DesignTools.MauiTap.ElementSelectionManager.RegisterWindow(IWindow window)
at Microsoft.VisualStudio.DesignTools.MauiTap.ElementSelectionManager.Initialize()
at Microsoft.Maui.Dispatching.Dispatcher.<>c__DisplayClass9_0.<DispatchImplementation>b__0()
at CoreFoundation.DispatchQueue.static_dispatcher_to_managed(IntPtr context)
at UIKit.UIApplication.xamarin_UIApplicationMain(Int32 argc, IntPtr argv, IntPtr principalClassName, IntPtr delegateClassName, IntPtr& gchandle)
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
To resolve this issue, I referred the microsoft article
and added the below to property group tags in *.csproj.
<UseInterpreter>true</UseInterpreter>
<MtouchInterpreter>all</MtouchInterpreter>