diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 2942fb23d3f82f..5328d982af6f03 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -3362,9 +3362,6 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e return (gpointer)no_llvmonly_interp_method_pointer; } - if (method->wrapper_type && method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) - return imethod; - #ifndef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE /* * Interp in wrappers get the argument in the rgctx register. If diff --git a/src/mono/mono/mini/mini-runtime.c b/src/mono/mono/mini/mini-runtime.c index d075623de8cf73..0318c3d1689bcc 100644 --- a/src/mono/mono/mini/mini-runtime.c +++ b/src/mono/mono/mini/mini-runtime.c @@ -2558,7 +2558,18 @@ compile_special (MonoMethod *method, MonoError *error) } else { MonoMethod *nm = mono_marshal_get_native_wrapper (method, TRUE, mono_aot_only); compiled_method = mono_jit_compile_method_jit_only (nm, error); - return_val_if_nok (error, NULL); + if (!compiled_method && mono_aot_only && mono_use_interpreter) { + // We failed to find wrapper in aot images, try interpreting it instead + mono_error_cleanup (error); + error_init_reuse (error); + nm = mono_marshal_get_native_wrapper (method, TRUE, FALSE); + compiled_method = mono_jit_compile_method (nm, error); + return_val_if_nok (error, NULL); + code = mono_get_addr_from_ftnptr (compiled_method); + return code; + } else { + return_val_if_nok (error, NULL); + } } code = mono_get_addr_from_ftnptr (compiled_method);