Forum Xamarin Xamarin.Android

Invalid IL Code at runtime after hybrid aot compilation

TimoDTimoD Member
edited February 12 in Xamarin.Android


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:


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)
            return value2;
            return value1;

JetBrains dotPeek shows the IL code as:

  .method public hidebysig static !!0/*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 ([email protected])
Xamarin.Android SDK (d16-4/e44d1ae)

What can cause this problem?

Thanks for every help!



Sign In or Register to comment.