locked
Invalid IL Code at runtime after hybrid aot compilation RRS feed

  • Question

  • User392746 posted

    Hello,

    My current customer has a Xamarin.Forms app, which will be published soon. For code protection reasons I tried hybrid aot compilation with the following settings:

        <AotAssemblies>true</AotAssemblies>
        <AndroidAotMode>Hybrid</AndroidAotMode>
        <AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments>
    

    The compilation succeeded and the IL code is no longer part of the assemblies. The methods are only stubs now.

    But at runtime, we're getting exceptions:

    System.InvalidProgramException: Invalid IL code in {my namespace}.{my class}:{my method} (single,single): IL_0000: ret

    The code of that method is:

            public static T MyMethod<T>(T value1, T value2)
            {
    #if {PRECOMPILER VAR}
                return value2;
    #else
                return value1;
    #endif
            }
    

    JetBrains dotPeek shows the IL code as:

      .method public hidebysig static !!0/*T*/
        MyMethod<T>(
          !!0/*T*/ 'value',
          !!0/*T*/ value2
        ) cil managed noinlining
      {
        .maxstack 8
    
        IL_0000: ret
      }
    

    The given method is not the only one. If I comment this one out, I get the same error in another method. May be, that they are all generic, but I don't know this exactly.

    Xamarin 16.4.000.311 (d16-4@ddfd842) Xamarin.Android SDK 10.1.4.0 (d16-4/e44d1ae)

    What can cause this problem?

    Thanks for every help! Timo

    Wednesday, February 12, 2020 11:51 AM

All replies