异常'尝试使用JIT编译方法,同时使用--aot-only'与Google.ProtocolBuffersLite一起运行

时间:2014-06-23 14:49:19

标签: ios mono unity3d protocol-buffers aot

我在Unity3d项目中使用的类库中使用Google.ProtocolBuffersLite。 当试图在IOS上的应用程序中的myClass.cs中使用ParseFrom(System.Byte [] data)函数时,我得到以下异常:

---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Collections.Generic.EqualityComparer`1 
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
---> System.ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.GenericEqualityComparer`1<Google.ProtocolBuffers.ExtensionRegistry/ExtensionIntPair>:.ctor ()' while running with --aot-only.

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 
  at System.Collections.Generic.EqualityComparer`1[Google.ProtocolBuffers.ExtensionRegistry+ExtensionIntPair]..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Collections.Generic.Dictionary`2[Google.ProtocolBuffers.ExtensionRegistry+ExtensionIntPair,Google.ProtocolBuffers.IGeneratedExtensionLite].Init (Int32 capacity, IEqualityComparer`1 hcp) [0x00000] in <filename unknown>:0 
  at System.Collections.Generic.Dictionary`2[Google.ProtocolBuffers.ExtensionRegistry+ExtensionIntPair,Google.ProtocolBuffers.IGeneratedExtensionLite]..ctor () [0x00000] in <filename unknown>:0 
  at Google.ProtocolBuffers.ExtensionRegistry..cctor () [0x00000] in <filename unknown>:0  Exception.Message: An exception was thrown by the type initializer for Google.ProtocolBuffers.ExtensionRegistry
at Google.ProtocolBuffers.AbstractBuilderLite`2[TMessage,TBuilder].MergeFrom (System.Byte[] data) [0x00000] in <filename unknown>:0 

使用protocolBuffersLite的过程是:

  1. 在我的.proto类中添加选项optimize_for = LITE_RUNTIME;
  2. 使用.proto类和Google.ProtocolBuffers.dll版本net20生成.cs类
  3. 将库存添加到我的库csharp proj .cs类和Google.ProtocolBuffersLite.dll
  4. 使用monoDevelop 2.8.2
  5. 进行编译
  6. 将myLibraryThatUseProtocol.dll和Google.ProtocolBuffersLite.dll移至myUnity3d项目
  7. 在Unity3D-&gt; Build Settings-&gt; IOS-&gt;我使用的PlayerSettings:

      

    Api兼容级别:.net 2.0子集

         

    Aot编译选项:空

         

    剥离级别:已禁用

  8.   
  9. 在Unity3d(版本4.2.0)中构建应用程序
  10.   
  11. 在Xcode中运行应用
  12.      如果有人能提供任何帮助,我将不胜感激。

0 个答案:

没有答案