Running app as pkg produces errors.

Dani_S 3,786 Reputation points
2024-08-26T12:15:43.7633333+00:00

Hi,

Use the following command to create a .pkg:

dotnet publish -f net8.0-maccatalyst -c Release

when running the app (net 8) i got this error:

what i need to do ?

2024-08-26 15:10:34,922 [1] ERROR GssdDesktopClient.Maui.Helpers.UtillHelper - GetDestinations

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) object object:Thunk1ret_Object_CallSite_Type_Object (System.Func`2<object[], object>,System.Runtime.CompilerServices.CallSite,System.Type,object)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

   at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed)

   at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure)

   at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method)

   at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type , Object )

   at System.Dynamic.Utils.DelegateHelpers.CreateObjectArrayDelegateRefEmit(Type , Func`2 )

   at System.Dynamic.Utils.DelegateHelpers.CreateObjectArrayDelegate(Type , Func`2 )

   at System.Linq.Expressions.Interpreter.LightLambda.MakeDelegate(Type )

   at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate(IStrongBox[] )

   at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate()

   at System.Linq.Expressions.Expression1[[System.Func4[[System.Runtime.CompilerServices.CallSite, System.Linq.Expressions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.Type, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKey

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

Accepted answer
  1. Bruce (SqlWork.com) 66,706 Reputation points
    2024-08-26T20:32:46.4333333+00:00

    when building for debug, a .net virtual machine is used, to allow debugging and fast deploy. the Apple Store does not allow virtual machine, so the app must be compiled via AOT. AOT compiles are more restrictive in what code is allowed (no reflection support for example).

    In your case NewtonSoft is not supported. you will need the AOT enabled System.Text.Json serializer, and must use the source generation feature:

    https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-8-0

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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