Bug 59972 - Operation is not supported on this platform. at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly
Summary: Operation is not supported on this platform. at System.Reflection.Emit.Assemb...
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler (show other bugs)
Version: XI 11.0 (xcode9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2017-10-05 00:40 UTC by Murf
Modified: 2017-10-05 05:47 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Murf 2017-10-05 00:40:31 UTC
I am having this problem with VS 2017 for Mac (Forms app targeting iOS 11)

Visual Studio Enterprise 2017 for Mac
Version 7.1.5 (build 2)

Apple Developer Tools
Xcode 9.0 (13247)
Build 9A235

Xamarin.iOS
Version: 11.0.0.0 (Visual Studio Enterprise)
Hash: 152b654a
Branch: xcode9
Build date: 2017-09-15 02:25:56-0400

Code:
using Xamarin.Forms;
using MessagePack;

namespace testMessagePack
{
    public partial class testMessagePackPage : ContentPage
    {
        public testMessagePackPage()
        {
            InitializeComponent();
			dynamic model = new { Name = "foobar", Items = new[] { 1, 10, 100, 1000 } };

            //Murf error occurs here:
			var bin = MessagePackSerializer.Serialize(model);

		}
    }
}


It is a runtime error (Exception) not a build error:


System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.StandardResolver' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Internal.StandardResolverCore' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MessagePack.Resolvers.DynamicEnumResolver' threw an exception. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
  at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs:37
  at MessagePack.Internal.DynamicAssembly..ctor (System.String moduleName) [0x0000d] in <890382a3318d4771b0f6a9ff91371336>:0
  at MessagePack.Resolvers.DynamicEnumResolver..cctor () [0x00010] in <890382a3318d4771b0f6a9ff91371336>:0
  --- End of ner exception stack trace ---
  at at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
  at MessagePack.Internal.StandardResolverCore..cctor () [0x0000a] in <890382a3318d4771b0f6a9ff91371336>:0
  --- End of inner exception stack trace ---
  --- End of inner exception stack trace ---
  at MessagePack.MessagePackSerializer.Serialize[T] (T obj, MessagePack.IFormatterResolver resolver) [0x00003] in <890382a3318d4771b0f6a9ff91371336>:0
  at MessagePack.MessagePackSerializer.Serialize[T] (T obj) [0x00000] in <890382a3318d4771b0f6a9ff91371336>:0
  at at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:174
  at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00035] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs:333
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63
  at System.Linq.Expressions.Interpreter.LightLambda.Run3[T0,T1,T2,TRet] (T0 arg0, T1 arg1, T2 arg2) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightLambda.Generated.cs:107
  at at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:174
  at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00083] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs:358
  at System.Linq.Expressions.Interpreter.EnterTryCatchFinallyInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00044] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/ControlFlowInstructions.cs:355
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63
  at System.Linq.Expressions.Interpreter.LightLambda.Run3[T0,T1,T2,TRet] (T0 arg0, T1 arg1, T2 arg2) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightLambda.Generated.cs:107
  at testMessagePack.testMessagePackPage..ctor () [0x0002b] in /Users/brettm/Projects/testMessagePack/testMessagePack/testMessagePackPage.xaml.cs:15
  at testMessagePack.App..ctor () [0x0000f] in /Users/brettm/Projects/testMessagePack/testMessagePack/App.xaml.cs:11
  at testMessagePack.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in /Users/brettm/Projects/testMessagePack/iOS/AppDelegate.cs:17
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/src/UIKit/UIApplication.cs:63
  at testMessagePack.iOS.Application.Main (System.String[] args) [0x00001] in /Users/brettm/Projects/testMessagePack/iOS/Main.cs:17
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-10-05 05:47:34 UTC
The MessagePack library is using a feature that's not available in Xamarin.iOS (dynamic code generation). See here for more information: https://developer.xamarin.com/guides/ios/advanced_topics/limitations/#No_Dynamic_Code_Generation

Note You need to log in before you can comment on or make changes to this bug.