.NET MAUI 8.0 错误:此平台不支持动态代码生成

问题描述 投票:0回答:1

我遇到以下异常

Dynamic code generation is not supported on this platform.

当尝试调试 .NET MAUI 8.0 应用程序时,更新到最新的 .net 8.0.7 运行时后会发生这种情况。

异常详情如下

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)
macos maui
1个回答
0
投票

为了解决这个问题,我参考了microsoft文章

并将以下内容添加到 *.csproj 中的属性组标记中。

<UseInterpreter>true</UseInterpreter>
<MtouchInterpreter>all</MtouchInterpreter>
© www.soinside.com 2019 - 2024. All rights reserved.